wrappers: For UWP, pass the default -lwindowsapp after user specified options
This matches how the compiler driver normally includes default linked libraries; the user provided -l flags are passed first, followed by the compiler's default ones. That allows a user specified library to override the default ones. This makes sure that if a user provides -lwindowsappcompat, it gets linked before -lwindowsapp, which makes a difference for symbols that are provided in both (such as e.g. LoadLibraryW).
This commit is contained in:
1 parent
e76e935c7d
commit
56fec2622f
2 files changed
+25
-9
No files matched your search
@@ -50,7 +50,7 @@ int _tmain(int argc, TCHAR* argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
int max_arg = argc + 20;
|
||||
int max_arg = argc + 22;
|
||||
const TCHAR **exec_argv = malloc((max_arg + 1) * sizeof(*exec_argv));
|
||||
int arg = 0;
|
||||
if (getenv("CCACHE"))
|
||||
@@ -84,11 +84,6 @@ int _tmain(int argc, TCHAR* argv[]) {
|
||||
exec_argv[arg++] = _T("-DWINAPI_FAMILY=WINAPI_FAMILY_APP");
|
||||
// the Windows Store API only supports Windows Unicode (some rare ANSI ones are available)
|
||||
exec_argv[arg++] = _T("-DUNICODE");
|
||||
// add the minimum runtime to use for UWP targets
|
||||
exec_argv[arg++] = _T("-Wl,-lwindowsapp");
|
||||
// This still requires that the toolchain (in particular, libc++.a) has
|
||||
// been built targeting UCRT originally.
|
||||
exec_argv[arg++] = _T("-Wl,-lucrtapp");
|
||||
// force the user of Universal C Runtime
|
||||
exec_argv[arg++] = _T("-D_UCRT");
|
||||
}
|
||||
@@ -104,6 +99,19 @@ int _tmain(int argc, TCHAR* argv[]) {
|
||||
for (int i = 1; i < argc; i++)
|
||||
exec_argv[arg++] = argv[i];
|
||||
|
||||
if (target_os && !_tcscmp(target_os, _T("mingw32uwp"))) {
|
||||
// Default linker flags; passed after any user specified -l options,
|
||||
// to let the user specified libraries take precedence over these.
|
||||
|
||||
exec_argv[arg++] = _T("--start-no-unused-arguments");
|
||||
// add the minimum runtime to use for UWP targets
|
||||
exec_argv[arg++] = _T("-Wl,-lwindowsapp");
|
||||
// This still requires that the toolchain (in particular, libc++.a) has
|
||||
// been built targeting UCRT originally.
|
||||
exec_argv[arg++] = _T("-Wl,-lucrtapp");
|
||||
exec_argv[arg++] = _T("--end-no-unused-arguments");
|
||||
}
|
||||
|
||||
exec_argv[arg] = NULL;
|
||||
if (arg >= max_arg) {
|
||||
fprintf(stderr, "Too many options added\n");
|
||||
|
||||
@@ -71,6 +71,7 @@ aarch64)
|
||||
# SEH is the default for aarch64.
|
||||
;;
|
||||
esac
|
||||
LINKER_FLAGS=""
|
||||
case $TARGET_OS in
|
||||
mingw32uwp)
|
||||
# the UWP target is for Windows 10
|
||||
@@ -79,11 +80,18 @@ mingw32uwp)
|
||||
FLAGS="$FLAGS -DWINAPI_FAMILY=WINAPI_FAMILY_APP"
|
||||
# the Windows Store API only supports Windows Unicode (some rare ANSI ones are available)
|
||||
FLAGS="$FLAGS -DUNICODE"
|
||||
|
||||
# Default linker flags; passed after any user specified -l options,
|
||||
# to let the user specified libraries take precedence over these.
|
||||
|
||||
# add the minimum runtime to use for UWP targets
|
||||
FLAGS="$FLAGS -Wl,-lwindowsapp"
|
||||
LINKER_FLAGS="$LINKER_FLAGS --start-no-unused-arguments"
|
||||
LINKER_FLAGS="$LINKER_FLAGS -Wl,-lwindowsapp"
|
||||
# This still requires that the toolchain (in particular, libc++.a) has
|
||||
# been built targeting UCRT originally.
|
||||
FLAGS="$FLAGS -Wl,-lucrtapp"
|
||||
LINKER_FLAGS="$LINKER_FLAGS -Wl,-lucrtapp"
|
||||
LINKER_FLAGS="$LINKER_FLAGS --end-no-unused-arguments"
|
||||
|
||||
# Force the Universal C Runtime
|
||||
FLAGS="$FLAGS -D_UCRT"
|
||||
;;
|
||||
@@ -96,4 +104,4 @@ FLAGS="$FLAGS -stdlib=libc++"
|
||||
FLAGS="$FLAGS -fuse-ld=lld"
|
||||
FLAGS="$FLAGS --end-no-unused-arguments"
|
||||
|
||||
$CCACHE "$CLANG" $FLAGS "$@"
|
||||
$CCACHE "$CLANG" $FLAGS "$@" $LINKER_FLAGS
|
||||
Reference in new issue
Block a user