Skip to content

Commit 74e4571

Browse files
committed
wrappers: Provide the unprefixed clang-scan-deps as a wrapper, on Windows
When setting up wrappers for Windows, rename clang-scan-deps.exe to clang-scan-deps-real.exe, make clang-scan-deps.exe a wrapper, and configure the wrapper to target executing clang-scan-deps-real.exe. This makes sure that we always pass in crucial options like -stdlib=libc++. By default, our Clang executables are built with that option hardcoded, configured with CLANG_DEFAULT_CXX_STDLIB=libc++ when built for Windows. However, we generally don't rely on this; we assume the tools could be plain default executables, so we try to provide wrappers on all common access paths.
1 parent 06bd759 commit 74e4571

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

install-wrappers.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ fi
114114
if [ -n "$EXEEXT" ]; then
115115
CLANG_MAJOR=$(basename $(echo $PREFIX/lib/clang/* | awk '{print $NF}') | cut -f 1 -d .)
116116
WRAPPER_FLAGS="$WRAPPER_FLAGS -municode -DCLANG=\"clang-$CLANG_MAJOR\""
117+
WRAPPER_FLAGS="$WRAPPER_FLAGS -DCLANG_SCAN_DEPS=\"clang-scan-deps-real\""
117118
fi
118119

119120
mkdir -p "$PREFIX/bin"
@@ -171,6 +172,9 @@ if [ -n "$EXEEXT" ]; then
171172
if [ ! -L clang$EXEEXT ] && [ -f clang$EXEEXT ] && [ ! -f clang-$CLANG_MAJOR$EXEEXT ]; then
172173
mv clang$EXEEXT clang-$CLANG_MAJOR$EXEEXT
173174
fi
175+
if [ ! -L clang-scan-deps$EXEEXT ] && [ -f clang-scan-deps$EXEEXT ] && [ ! -f clang-scan-deps-real$EXEEXT ]; then
176+
mv clang-scan-deps$EXEEXT clang-scan-deps-real$EXEEXT
177+
fi
174178
if [ -z "$HOST" ]; then
175179
HOST=$(./clang-$CLANG_MAJOR -dumpmachine | sed 's/-.*//')-w64-mingw32
176180
fi
@@ -179,7 +183,7 @@ if [ -n "$EXEEXT" ]; then
179183
# we are installing wrappers for.
180184
case $ARCHS in
181185
*$HOST_ARCH*)
182-
for exec in clang clang++ gcc g++ c++ addr2line ar dlltool ranlib nm objcopy readelf size strings strip windres; do
186+
for exec in clang clang++ gcc g++ c++ addr2line ar dlltool ranlib nm objcopy readelf size strings strip windres clang-scan-deps; do
183187
ln -sf $HOST-$exec$EXEEXT $exec$EXEEXT
184188
done
185189
for exec in cc c99 c11; do

wrappers/clang-scan-deps-wrapper.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
#include "native-wrapper.h"
2020

21+
#ifndef CLANG_SCAN_DEPS
22+
#define CLANG_SCAN_DEPS "clang-scan-deps"
23+
#endif
2124
#ifndef DEFAULT_TARGET
2225
#define DEFAULT_TARGET "x86_64-w64-mingw32"
2326
#endif
@@ -29,7 +32,7 @@ int _tmain(int argc, TCHAR *argv[]) {
2932
int max_arg = argc + 3;
3033
const TCHAR **exec_argv = malloc((max_arg + 1) * sizeof(*exec_argv));
3134
int arg = 0;
32-
exec_argv[arg++] = concat(dir, _T("clang-scan-deps"));
35+
exec_argv[arg++] = concat(dir, _T(CLANG_SCAN_DEPS));
3336

3437
// If changing this wrapper, change clang-scan-deps-wrapper.sh accordingly.
3538
int i = 1;

0 commit comments

Comments
 (0)