Skip to content

Commit 39d6c9b

Browse files
committed
wrappers: Use config files for setting defaults
1 parent e0af4d1 commit 39d6c9b

11 files changed

+24
-30
lines changed

install-wrappers.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ fi
122122

123123
mkdir -p "$PREFIX/bin"
124124
cp wrappers/*-wrapper.sh "$PREFIX/bin"
125+
cp wrappers/musl-common.cfg "$PREFIX/bin"
126+
for arch in $ARCHS; do
127+
cp wrappers/$arch*.cfg $PREFIX/bin
128+
done
125129
if [ -n "$HOST" ] && [ -n "$EXEEXT" ]; then
126130
# TODO: If building natively on msys, pick up the default HOST value from there.
127131
WRAPPER_FLAGS="$WRAPPER_FLAGS -DDEFAULT_TARGET=\"$HOST\""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-target aarch64-linux-musl
2+
@musl-common.cfg
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-target armv7-linux-musleabihf
2+
@musl-common.cfg
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-target armv7-linux-musleabihf
2+
@musl-common.cfg

wrappers/clang-target-wrapper.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ int _tmain(int argc, TCHAR* argv[]) {
3232
split_argv(argv[0], &dir, NULL, &target, &exe);
3333
if (!target)
3434
target = _T(DEFAULT_TARGET);
35-
TCHAR *arch = _tcsdup(target);
36-
TCHAR *dash = _tcschr(arch, '-');
37-
TCHAR *target_without_arch = NULL;
38-
if (dash) {
39-
*dash = '\0';
40-
target_without_arch = dash + 1;
41-
}
4235

4336
TCHAR *basedir = _tcsdup(dir);
4437
size_t basedirlen = _tcslen(basedir);
@@ -48,12 +41,6 @@ int _tmain(int argc, TCHAR* argv[]) {
4841
TCHAR *sep = _tcsrchrs(basedir, '/', '\\');
4942
if (sep)
5043
*(sep + 1) = '\0';
51-
TCHAR *sysroot = concat(basedir, _T("generic-linux-musl"));
52-
if (!_tcscmp(arch, _T("arm"))) {
53-
arch = _T("armv7");
54-
if (target_without_arch)
55-
target = concat(_T("armv7-"), target_without_arch);
56-
}
5744

5845
// Check if trying to compile Ada; if we try to do this, invoking clang
5946
// would end up invoking <triplet>-gcc with the same arguments, which ends
@@ -65,7 +52,7 @@ int _tmain(int argc, TCHAR* argv[]) {
6552
}
6653
}
6754

68-
int max_arg = argc + 18;
55+
int max_arg = argc + 17;
6956
const TCHAR **exec_argv = malloc((max_arg + 1) * sizeof(*exec_argv));
7057
int arg = 0;
7158
if (getenv("CCACHE"))
@@ -83,11 +70,6 @@ int _tmain(int argc, TCHAR* argv[]) {
8370

8471
exec_argv[arg++] = _T("-target");
8572
exec_argv[arg++] = target;
86-
exec_argv[arg++] = concat(_T("--sysroot="), sysroot);
87-
exec_argv[arg++] = _T("-rtlib=compiler-rt");
88-
exec_argv[arg++] = _T("-unwindlib=libunwind");
89-
exec_argv[arg++] = _T("-stdlib=libc++");
90-
exec_argv[arg++] = _T("-fuse-ld=lld");
9173
exec_argv[arg++] = _T("--end-no-unused-arguments");
9274

9375
for (int i = 1; i < argc; i++)

wrappers/clang-target-wrapper.sh

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ DEFAULT_TARGET=x86_64-linux-musl
3232
if [ "$TARGET" = "$BASENAME" ]; then
3333
TARGET=$DEFAULT_TARGET
3434
fi
35-
ARCH="${TARGET%%-*}"
3635
SYSROOT="$(dirname "$DIR")/generic-linux-musl"
37-
if [ "$ARCH" = "arm" ]; then
38-
# Convert arm-linux-musleabihf into armv7-linux-musleabihf
39-
ARCH=armv7
40-
TARGET=$ARCH-${TARGET#*-}
41-
fi
4236

4337
# Check if trying to compile Ada; if we try to do this, invoking clang
4438
# would end up invoking <triplet>-gcc with the same arguments, which ends
@@ -74,11 +68,6 @@ c11)
7468
esac
7569

7670
FLAGS="$FLAGS -target $TARGET"
77-
FLAGS="$FLAGS --sysroot=$SYSROOT"
78-
FLAGS="$FLAGS -rtlib=compiler-rt"
79-
FLAGS="$FLAGS -unwindlib=libunwind"
80-
FLAGS="$FLAGS -stdlib=libc++"
81-
FLAGS="$FLAGS -fuse-ld=lld"
8271
FLAGS="$FLAGS --end-no-unused-arguments"
8372

8473
$CCACHE "$CLANG" $FLAGS "$@" $LINKER_FLAGS
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-target i386-linux-musl
2+
@musl-common.cfg

wrappers/musl-common.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--sysroot=<CFGDIR>/../generic-linux-musl
2+
-rtlib=compiler-rt
3+
-unwindlib=libunwind
4+
-stdlib=libc++
5+
-fuse-ld=lld
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-target powerpc64le-linux-musl
2+
@musl-common.cfg
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-target riscv64-linux-musl
2+
@musl-common.cfg

0 commit comments

Comments
 (0)