Skip to content

Commit 75c4092

Browse files
committed
Add a script for preparing a cross-built toolchain for the unix layout
1 parent 8f3c096 commit 75c4092

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

prepare-cross-toolchain-unix.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2022 Martin Storsjo
4+
#
5+
# Permission to use, copy, modify, and/or distribute this software for any
6+
# purpose with or without fee is hereby granted, provided that the above
7+
# copyright notice and this permission notice appear in all copies.
8+
#
9+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16+
17+
set -e
18+
19+
if [ $# -lt 2 ]; then
20+
echo $0 src dest
21+
exit 1
22+
fi
23+
SRC="$1"
24+
DEST="$2"
25+
26+
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
27+
28+
CLANG_RESOURCE_DIR="$("$SRC/bin/clang" --print-resource-dir)"
29+
CLANG_VERSION=$(basename "$CLANG_RESOURCE_DIR")
30+
31+
# Copy the clang resource files (include, lib, share). The clang cross
32+
# build installs the main headers, but since we didn't build the runtimes
33+
# (compiler-rt), we're lacking the files that are installed by them. The
34+
# compiler-rt build primarily installs some libs, but also a few files under
35+
# share, and headers for some of the runtime libraries.
36+
#
37+
# Instead of trying to merge these files on top of the headers installed
38+
# by the clang cross build, just wipe the existing files and copy the whole
39+
# resource directory from the complete toolchain. As long as it's a matching
40+
# version of clang, the headers that were installed by it should be identical.
41+
#
42+
# Alternatively, we could copy the lib and share subdirectories, and
43+
# copy the individual include subdirectories that are missing.
44+
rm -rf $DEST/lib/clang/$CLANG_VERSION
45+
cp -a $CLANG_RESOURCE_DIR $DEST/lib/clang/$CLANG_VERSION
46+
47+
# Copy all arch-specific subdirectories plus the "generic" one, as is.
48+
for arch in generic $ARCHS; do
49+
cp -a $SRC/$arch-w64-mingw32 $DEST/$arch-w64-mingw32
50+
done

0 commit comments

Comments
 (0)