136 Commits

Author SHA1 Message Date
Martin Storsjö 8fb8fb4b05 build-busybox: Add a script for building busybox for Windows 2026-01-08 11:32:12 +02:00
Billy Laws 7b66916f51 wrappers: Add arm64ec support to ld-wrapper.sh 2025-04-30 12:06:31 +03:00
Jacek Caban fb25da229a wrappers: Add arm64ec-w64-windows-gnu.cfg 2025-04-30 12:06:31 +03:00
Martin Storsjö 63691c69bc wrappers: Skip the clang-scan-deps wrapper script on Unix
The wrapper script no longer has any purpose on Unix.

Just do a plain symlink to the clang-scan-deps tool.

On Windows, the wrapper executable still is used to inject a
default -target option, if the executable name doesn't contain
a triple.
2024-11-06 11:40:31 +02:00
Martin Storsjö ff505bf06a wrappers: Remove an explicit -stdlib=libc++ in clang-scan-deps-wrapper
This gets set by the config file.
2024-11-06 11:40:31 +02:00
Martin Storsjö eb6d71a82f wrappers: Don't explicitly pass -target in clang-scan-deps-wrapper.sh
clang-scan-deps can pick it up automatically from the first argument
now.

For the windows wrapper, keep passing -target, to allow running with
a potentially foreign clang-scan-deps.exe.
2024-11-06 11:40:31 +02:00
Martin Storsjö 6bd54a4fc2 wrappers: Move common arguments into a shared config file 2024-11-06 11:40:31 +02:00
Martin Storsjö 866d47cced wrappers: Pick up the Clang config file implicitly
Clang only picks up config files implicitly using the normalized
triple form, so use file names with "-windows-gnu" instead of
"-mingw32".

In theory, we could also want to pick up the config file implicitly
by having "<triple>-<mode>" be a symlink directly to the clang
executable. That works for regular mingw32 targets, but for the
mingw32uwp target, there's no distinction in the normalized
triple, so both would end up using the same "-windows-gnu" config
files. So as long as we want to support the mingw32uwp prefixed
tools, we need to use a wrapper.
2024-11-06 11:40:30 +02:00
Martin Storsjö e2e9216853 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.
2024-11-06 11:40:30 +02:00
Martin Storsjö e0964ce24c Revert use of Clang config files
This reverts commit 49db4a3a15,
9f1f0104f1,
4f95c14adf,
c34dc64028,
570fdcd251,
4bff0298c5 and
6939aee0c0.

When relying on Clang config files, two issues appeared:

- Running the compiler-rt tests fails, because the compiler-rt tests
  disable any default config files, breaking the compiler
  in this case:
  https://github.com/llvm/llvm-project/blob/llvmorg-19.1.1/compiler-rt/test/lit.common.cfg.py#L983

- Wine fails to build using llvm-mingw as cross compiler, because
  Wine adds the --no-default-config flag to Clang while compiling,
  if supported:
  https://gitlab.winehq.org/wine/wine/-/blob/wine-9.19/configure.ac?ref_type=tags#L866-868
  This causes llvm-mingw to omit the -rtlib=compiler-rt option
  (specified in a config file), making the compiler look for libgcc
  instead. Doing a check to see that linking succeeds doesn't necessarily
  help here - such a check already exists, but it tests linking with
  -nostdlib -nodefaultlibs:
  https://gitlab.winehq.org/wine/wine/-/blob/wine-9.19/aclocal.m4?ref_type=tags#L193-L206
2024-10-14 16:35:17 +03:00
Martin Storsjö 9f1f0104f1 wrappers: Skip the clang-scan-deps wrapper script on Unix
The wrapper script no longer has any purpose on Unix.

Just do a plain symlink to the clang-scan-deps tool.

On Windows, the wrapper executable still is used to inject a
default -target option, if the executable name doesn't contain
a triple.
2024-10-02 16:06:01 +03:00
Martin Storsjö 4f95c14adf wrappers: Remove an explicit -stdlib=libc++ in clang-scan-deps-wrapper
This gets set by the config file.
2024-10-02 16:06:01 +03:00
Martin Storsjö c34dc64028 wrappers: Don't explicitly pass -target in clang-scan-deps-wrapper.sh
clang-scan-deps can pick it up automatically from the first argument
now.

For the windows wrapper, keep passing -target, to allow running with
a potentially foreign clang-scan-deps.exe.
2024-10-02 16:06:01 +03:00
Martin Storsjö 570fdcd251 wrappers: Move common arguments into a shared config file 2024-10-02 15:58:01 +03:00
Martin Storsjö 4bff0298c5 wrappers: Pick up the Clang config file implicitly
Clang only picks up config files implicitly using the normalized
triple form, so use file names with "-windows-gnu" instead of
"-mingw32".

In theory, we could also want to pick up the config file implicitly
by having "<triple>-<mode>" be a symlink directly to the clang
executable. That works for regular mingw32 targets, but for the
mingw32uwp target, there's no distinction in the normalized
triple, so both would end up using the same "-windows-gnu" config
files. So as long as we want to support the mingw32uwp prefixed
tools, we need to use a wrapper.
2024-10-02 15:58:00 +03:00
Martin Storsjö 6939aee0c0 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.
2024-10-02 15:58:00 +03:00
Martin Storsjö e9e2ef7d53 wrappers: Unify handling of CMD_EXE in clang-scan-deps-wrapper.sh
If we never set $TARGET, we'd previously miss including $CMD_EXE
in the nested command. (This doesn't happen in actual uses of
the wrapper though, but is included for completeness.)

This matches how the corresponding variable is handled in the C
version of the wrapper.
2024-10-02 15:58:00 +03:00
Martin Storsjö 1eda3dcc2e wrappers: Fix a comment wording issue
This comment was added worded slightly differently in the native
version of the wrapper, compared to the shell script, in
26e56ed5f6.
2024-07-30 14:09:39 +03:00
Martin Storsjö ebde97faaf wrappers: Use a response file on Windows, if the new command line seems too long
This should properly fix the issue that was reported at
https://github.com/mstorsjo/llvm-mingw/issues/296.
2024-06-03 12:36:17 +03:00
Martin Storsjö 089c625e66 wrappers: Print an understandable error if the total command line ends up too long
This can happen if the input command line is barely under the limit,
but ends up exceeding it due to the extra arguments that the wrapper
adds.

One could hope that _tspawnvp would set errno to a helpful error code,
to identify the issue when printing the error with _tperror(), but in
practice, it doesn't.
2024-06-03 12:36:17 +03:00
Martin Storsjö 3847488786 wrappers: Only escape arguments that need escaping
This avoids inflating the total size of the command line too much.

If the input command line is near the max size of a command line
(32767 characters), it may grow past that limit when adding the
arguments injected by the wrapper. If we excessively quote all
arguments that don't need to be quoted, we can more easily run
into this situation.

Thus, by avoiding excessive quoting, we reduce the risk for this
issue to happen.

This avoids the issue reported at
https://github.com/mstorsjo/llvm-mingw/issues/296.
2024-06-03 12:36:07 +03:00
Martin Storsjö 74e45715e3 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.
2024-05-02 20:03:56 +03:00
Martin Storsjö 06bd759e50 wrappers: Add a wrapper for clang-scan-deps
This picks the architecture by looking for a triple prefix in the
nested command, and passes it as an explicit flag, to let
clang-scan-deps find it.

We also pass -stdlib=libc++, to let it find the libc++ headers
as expected.
2024-05-02 20:03:56 +03:00
Martin Storsjö 340e2e7f0b wrappers: Fix the comparison against max_args in clang-target-wrapper
Since we allocate max_args+1 elements, with one extra for the
null terminator, it's ok if we've used up to max_args elements
already.
2024-04-24 11:36:42 +03:00
Martin Storsjö 9de1bfe8a3 wrappers: Fix a typo 2024-04-24 11:36:31 +03:00
Martin Storsjö 3184cb2060 wrappers: Don't rely on "readlink -f"
Older macOS versions (macOS 12.2 at least) don't support this
option, while newer macOS versions do support it (macOS 12.6).

The solution is based on https://stackoverflow.com/a/1116890/3115956,
but simplified for this usecase.
2023-05-23 11:23:27 +03:00
Dave Nicolson cdf05bbc50 Fix symlink paths 2023-05-22 23:55:06 +03:00
Martin Storsjö 1022231482 wrappers: Try to resolve short form 8.3 file names into long form
This allows the wrappers to invoke the right tool with the right
options, even when the wrapper was invoked with an obfuscated
short form file name.

This happens e.g. when CMake/Ninja invokes the tools from a path
that contains spaces.
2023-03-12 00:08:13 +02:00
Martin Storsjö 087255e28a wrappers: Handle tools named [<target>-]llvm-<tool>
Normally, we'd split the string at the last dash. However if the
tool name is "llvm-<tool>", make sure to include "llvm-" in the
tool name part when splitting the executable name.

In llvm-wrapper, don't add a duplicate "llvm-" prefix for the tool
name in these cases.
2022-10-01 13:28:41 +03:00
Martin Storsjö 2f8b90b583 wrappers: Reorder some lines in clang-target-wrapper.sh for consistency 2022-10-01 13:28:02 +03:00
Martin Storsjö 56fec2622f 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).
2022-10-01 13:28:02 +03:00
Martin Storsjö 5ecaf6ce2c wrappers: Update the comment about what unwind method is used on armv7
Since fcb784db496137fa29a11b7e106efe89c7550e11 in llvm-project
(Jun 6th), the armv7 target uses SEH.
2022-07-31 01:08:30 +03:00
Martin Storsjö 52d7bee3a8 wrappers: Set the right -std= arguments when invoked as c99/c11 2022-06-08 23:11:40 +03:00
Martin Storsjö faa0a22955 Revert "wrappers: Force the default dwarf version back to 4"
This reverts commit e384109cbf.

This workaround no longer is necessary after LLVM 14.0.0 RC2.
2022-03-03 22:58:32 +02:00
Martin Storsjö e384109cbf wrappers: Force the default dwarf version back to 4
Clang's general default dwarf version was raised from 4 to 5 in
d3b26dea16108c427b19b5480c9edc76edf8f5b4 in llvm-project (Jan 23
2022) before the 14.0.0 branch, but dwarf 5 on Windows seems to not
work with either LLDB or GDB.

Thus force the default back to 4 here as a temporary workaround, and try
to set the default back to 4 for mingw targets in Clang for later
releases (https://reviews.llvm.org/D119326).
2022-02-09 15:39:43 +02:00
Martin Storsjö 977df0d83e wrappers: Fix an incorrect check for the max number of arguments in clang-target-wrapper.c 2022-02-09 15:39:43 +02:00
Martin Storsjö 14db168cd6 wrappers: Use --{start,end}-no-unused-arguments instead of -Qunused-arguments
This makes warnings for other unused arguments visible to the user.

This requires a version of llvm-project past
50ec1306d060e46e0d53c9f5d8a052e1b0d10d3b (Jan 2022) which added these
new options.
2022-02-09 14:02:20 +02:00
Martin Storsjö 56d0ef7900 wrappers: Remove hacks for filtering the stdout from clang
Since df0ba47c36f6bd0865e3286853b76d37e037c2d7 in llvm-project
(November 5th 2021), clang built with mingw defaults to producing
paths with forward slashes - thus, this hack no longer is needed.
2022-02-09 14:02:20 +02:00
Martin Storsjö e35ef3b7d7 Use -unwindlib=libunwind instead of merging libunwind into libc++
This makes the build of libcxx a bit cleaner, and simplifies later
building and testing of libcxx.
2021-10-01 12:31:51 +03:00
Martin Storsjö 42d2eb7346 wrappers: Remove the dlltool wrapper
Since LLVM 13, llvm-dlltool can imply the target architecture from
a triple prefix on the tool name, so there's no more need for a
wrapper.

The *-dlltool tools are now symlinks to the main llvm-dlltool
executable. In the Windows distribution, the *-dlltool.exe used to be
copies of dlltool-wrapper.exe (which is small; 15 KB). Now they
will instead be copies of llvm-dlltool.exe. Luckily, thanks to
building with -DLLVM_LINK_LLVM_DYLIB=ON by default, llvm-dlltool.exe
is only a mere 65 KB, while it used to be much larger, e.g. around
11 MB in older releases.
2021-09-17 11:09:35 +03:00
Martin Storsjö 8915db817c wrappers: Remove windres-wrapper; llvm-windres is available since LLVM 13.0.0 2021-08-09 12:08:16 +03:00
Martin Storsjö ea46c8d98f build-openmp.sh: Use llvm-ml instead of uasm 2021-08-09 12:08:16 +03:00
Martin Storsjö 459e37f03f wrappers: Convert dlltool-wrapper to a native executable
This allows running it on windows from processes other than msys
based ones.
2021-06-14 11:44:06 +03:00
Martin Storsjö b34e1cd82b windres-wrapper: Don't leave the .preproc.rc behind if producing .res 2021-04-09 13:42:29 +03:00
Martin Storsjö c3529a6b9b windres-wrapper: Implement support for the --preprocessor option 2021-03-10 10:22:06 +02:00
Martin Storsjö d5cda17953 wrappers: Return 0 when printing help in the windres wrapper 2020-11-21 21:34:50 +02:00
Russell Haley 5497454d16 Update windres-wrapper --version to return 0
modified:   wrappers/windres-wrapper.c - print_version now passes 0 to
exit function.
2020-11-21 21:33:14 +02:00
Martin Storsjö 9031eb6791 Build the OpenMP runtime in docker based builds
LLVM's OpenMP implementation only supports Windows on x86, and it
requires a MASM-compatible assembler to build it. Build UASM
for this purpose, for now. (UASM isn't available packaged in
debian/ubuntu repos.) In the future, llvm-ml should be able
to handle it instead, but it's not currently mature enough.

Not including it in the regular build-all.sh for now, as UASM
isn't generally available.
2020-10-15 23:23:05 +03:00
Martin Storsjö 41f4f3fac6 wrappers: Filter backslashes into forward slashes for --print-search-dirs similarly to -v 2020-08-20 13:29:44 +03:00
Martin Storsjö ab4220fd2a wrappers: Remove a misplaced, unnecessary pair of braces 2020-08-20 12:56:39 +03:00