Skip to content

Commit 6939aee

Browse files
committed
wrappers: Use clang config files for defaults
This makes these defaults more easy to get picked up in various use cases, when not directly executing a compiler.
1 parent e9e2ef7 commit 6939aee

10 files changed

+34
-39
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ARG CFGUARD_ARGS=--enable-cfguard
2424

2525
# Build everything that uses the llvm monorepo. We need to build the mingw runtime before the compiler-rt/libunwind/libcxxabi/libcxx runtimes.
2626
COPY build-llvm.sh build-lldb-mi.sh strip-llvm.sh install-wrappers.sh build-mingw-w64.sh build-mingw-w64-tools.sh build-compiler-rt.sh build-libcxx.sh build-mingw-w64-libraries.sh build-openmp.sh ./
27-
COPY wrappers/*.sh wrappers/*.c wrappers/*.h ./wrappers/
27+
COPY wrappers/*.sh wrappers/*.c wrappers/*.h wrappers/*.cfg ./wrappers/
2828
RUN ./build-llvm.sh $TOOLCHAIN_PREFIX && \
2929
./build-lldb-mi.sh $TOOLCHAIN_PREFIX && \
3030
./strip-llvm.sh $TOOLCHAIN_PREFIX && \

Dockerfile.cross

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
5454
COPY build-mingw-w64.sh build-mingw-w64-tools.sh ./
5555
RUN ./build-mingw-w64-tools.sh $CROSS_TOOLCHAIN_PREFIX --skip-include-triplet-prefix --host=$HOST
5656

57-
COPY wrappers/*.sh wrappers/*.c wrappers/*.h ./wrappers/
57+
COPY wrappers/*.sh wrappers/*.c wrappers/*.h wrappers/*.cfg ./wrappers/
5858
COPY install-wrappers.sh .
5959
RUN ./install-wrappers.sh $CROSS_TOOLCHAIN_PREFIX --host=$HOST
6060

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN ./strip-llvm.sh $TOOLCHAIN_PREFIX
3737
ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
3838

3939
# Install the usual $TUPLE-clang binaries
40-
COPY wrappers/*.sh wrappers/*.c wrappers/*.h ./wrappers/
40+
COPY wrappers/*.sh wrappers/*.c wrappers/*.h wrappers/*.cfg ./wrappers/
4141
COPY install-wrappers.sh ./
4242
RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX
4343

install-wrappers.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ fi
123123

124124
mkdir -p "$PREFIX/bin"
125125
cp wrappers/*-wrapper.sh "$PREFIX/bin"
126+
for arch in $ARCHS; do
127+
cp wrappers/$arch-w64-mingw32.cfg $PREFIX/bin
128+
done
126129
if [ -n "$HOST" ] && [ -n "$EXEEXT" ]; then
127130
# TODO: If building natively on msys, pick up the default HOST value from there.
128131
WRAPPER_FLAGS="$WRAPPER_FLAGS -DDEFAULT_TARGET=\"$HOST\""

wrappers/aarch64-w64-mingw32.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-target aarch64-w64-mingw32
2+
-rtlib=compiler-rt
3+
-unwindlib=libunwind
4+
-stdlib=libc++
5+
-fuse-ld=lld
6+
# SEH is the default for aarch64.

wrappers/armv7-w64-mingw32.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-target armv7-w64-mingw32
2+
-rtlib=compiler-rt
3+
-unwindlib=libunwind
4+
-stdlib=libc++
5+
-fuse-ld=lld
6+
# SEH is the default for armv7.

wrappers/clang-target-wrapper.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int _tmain(int argc, TCHAR* argv[]) {
5050
}
5151
}
5252

53-
int max_arg = argc + 22;
53+
int max_arg = argc + 18;
5454
const TCHAR **exec_argv = malloc((max_arg + 1) * sizeof(*exec_argv));
5555
int arg = 0;
5656
if (getenv("CCACHE"))
@@ -66,16 +66,6 @@ int _tmain(int argc, TCHAR* argv[]) {
6666
else if (!_tcscmp(exe, _T("c11")))
6767
exec_argv[arg++] = _T("-std=c11");
6868

69-
if (!_tcscmp(arch, _T("i686"))) {
70-
// Dwarf is the default for i686.
71-
} else if (!_tcscmp(arch, _T("x86_64"))) {
72-
// SEH is the default for x86_64.
73-
} else if (!_tcscmp(arch, _T("armv7"))) {
74-
// SEH is the default for armv7.
75-
} else if (!_tcscmp(arch, _T("aarch64"))) {
76-
// SEH is the default for aarch64.
77-
}
78-
7969
if (target_os && !_tcscmp(target_os, _T("mingw32uwp"))) {
8070
// the UWP target is for Windows 10
8171
exec_argv[arg++] = _T("-D_WIN32_WINNT=0x0A00");
@@ -88,12 +78,8 @@ int _tmain(int argc, TCHAR* argv[]) {
8878
exec_argv[arg++] = _T("-D_UCRT");
8979
}
9080

91-
exec_argv[arg++] = _T("-target");
92-
exec_argv[arg++] = target;
93-
exec_argv[arg++] = _T("-rtlib=compiler-rt");
94-
exec_argv[arg++] = _T("-unwindlib=libunwind");
95-
exec_argv[arg++] = _T("-stdlib=libc++");
96-
exec_argv[arg++] = _T("-fuse-ld=lld");
81+
exec_argv[arg++] = _T("--config");
82+
exec_argv[arg++] = concat(arch, _T("-w64-mingw32.cfg"));
9783
exec_argv[arg++] = _T("--end-no-unused-arguments");
9884

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

wrappers/clang-target-wrapper.sh

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,6 @@ c11)
6767
FLAGS="$FLAGS -std=c11"
6868
;;
6969
esac
70-
case $ARCH in
71-
i686)
72-
# Dwarf is the default for i686.
73-
;;
74-
x86_64)
75-
# SEH is the default for x86_64.
76-
;;
77-
armv7)
78-
# SEH is the default for armv7.
79-
;;
80-
aarch64)
81-
# SEH is the default for aarch64.
82-
;;
83-
esac
8470
LINKER_FLAGS=""
8571
case $TARGET_OS in
8672
mingw32uwp)
@@ -106,11 +92,7 @@ mingw32uwp)
10692
;;
10793
esac
10894

109-
FLAGS="$FLAGS -target $TARGET"
110-
FLAGS="$FLAGS -rtlib=compiler-rt"
111-
FLAGS="$FLAGS -unwindlib=libunwind"
112-
FLAGS="$FLAGS -stdlib=libc++"
113-
FLAGS="$FLAGS -fuse-ld=lld"
95+
FLAGS="$FLAGS --config $ARCH-w64-mingw32.cfg"
11496
FLAGS="$FLAGS --end-no-unused-arguments"
11597

11698
$CCACHE "$CLANG" $FLAGS "$@" $LINKER_FLAGS

wrappers/i686-w64-mingw32.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-target i686-w64-mingw32
2+
-rtlib=compiler-rt
3+
-unwindlib=libunwind
4+
-stdlib=libc++
5+
-fuse-ld=lld
6+
# Dwarf is the default for i686.

wrappers/x86_64-w64-mingw32.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-target x86_64-w64-mingw32
2+
-rtlib=compiler-rt
3+
-unwindlib=libunwind
4+
-stdlib=libc++
5+
-fuse-ld=lld
6+
# SEH is the default for x86_64.

0 commit comments

Comments
 (0)