52 Commits
Author SHA1 Message Date
Ole André Vadla Ravnås f58325abd0 env: Link libstdc++ dynamically in system builds
-static-libstdc++ is for portable prebuilt binaries. A build against
system libraries should use the shared libstdc++ like any other distro
package, and Fedora does not even ship the static archive by default.
2026-10-20 17:12:51 +02:00
Ole André Vadla Ravnås 4d1a68aaac env: Allow % in compiler and linker flags
dpkg-buildflags now adds -Wl,--package-metadata=<url-encoded JSON>,
which ConfigParser rejects under its default interpolation. Machine
files are not interpolated, so turn it off.
2026-10-20 16:45:15 +02:00
Ole André Vadla Ravnås 5de858c54f env: Pass windres to Meson when available
GLib now compiles Windows resources, so MinGW builds need it.
2026-10-14 21:46:46 +02:00
Ole André Vadla Ravnås c43b80fe2d Support a bare ARMv7-A machine
The generic ARM flags name armv5t, which has neither Thumb-2 nor the
divide a Cortex-A7 has, and nothing took the float out of the ABI.
Clang also wants the eabi environment rather than elf.
2026-09-02 00:15:36 +02:00
Ole André Vadla Ravnås de49bff33d env: Keep -dead_strip off bare-metal links
The flavor is detected from the driver's own linker, which on macOS
is Apple's, while a bare-metal target links with LLD. LLD refuses
the option, so every link probe fails and each feature behind one
is detected as missing.
2026-08-27 17:46:13 +02:00
Ole André Vadla Ravnås 0cb8c69c7c Make bare addressing an explicit config tag
Read the config as a set of tags, thus a bare flavor says in its name
whether its code is position-independent: softfloat becomes
softfloat_nopic, and softfloat_msabi becomes softfloat_pic_msabi. This
also gives x86 a position-independent flavor, which it had no way to
name before.

A bare target is soft-float in each case now, thus remove the newlib
path that the other targets took.
2026-08-17 11:58:21 +02:00
Ole André Vadla Ravnås f6b1b84279 Say what a bare-metal target needs to be built
The SDK that would have supplied a compiler is what is being built,
so either a triplet names the toolchain or the tools are named
outright. "No C compiler found" on a box full of them helps nobody.
2026-08-16 18:04:05 +02:00
Ole André Vadla Ravnås c17fd5c7c4 Add a bare x86_64 flavor for Windows kernels
The one we had suits a Linux module: System V, and not position
independent — the module loader resolves no GOT relocation, and the
kernel code model expects the top 2GB. A Windows kernel follows
another convention, and the agent's text is mapped a second time
into each instrumented process, shared, so that flavor is position
independent instead.

Soft float is what kernel mode means rather than what either
convention says, so both carry it. The convention is a property of
the machine rather than the toolchain, so it rides in the machine
file for whoever generates or inspects the code.
2026-08-16 18:03:59 +02:00
Ole André Vadla Ravnås 0ad9eef364 Link the bare soft-float flavor no-pie
Everything in it is built -fno-pic, so a distribution whose driver
defaults to PIE rejects the resulting R_386_32 relocations outright.
Only 32-bit x86 minds, its addressing having nowhere else to go.

Straight to the linker: clang swallows the driver spelling when it is
gcc doing the link.
2026-08-13 17:53:44 +02:00
Ole André Vadla Ravnås b2d3be9088 Add the none-x86-softfloat flavor
Share the soft-float flags both x86 bitnesses need and keep the
64-bit-only ones — the red zone, the kernel code model and the IBT
pair — with x86_64. clang has no i386 bare-metal triple under the
arch's own name, so map it to i686, and skip the hard-float arch
flags, which -mfpmath=sse would contradict.
2026-08-13 12:52:01 +02:00
Ole André Vadla Ravnås 8d9cddd772 Compile x86_64 softfloat without jump tables
A jump table is reached by an indirect jump, which the compiler marks
notrack and an IBT kernel does not permit, having left NOTRACK_EN clear.
Its own C is compiled this way for the same reason.
2026-08-12 22:22:28 +02:00
Ole André Vadla Ravnås acaad16801 Add none-x86_64-softfloat support
Soft-float on x86_64 is LLVM's +soft-float feature, which is what Rust's
own x86_64-unknown-none turns on, so both halves of a kernel-mode build
agree on where a double travels. -mno-sse alone does not reach the ABI.
long double has to be narrowed as well: soft-float has no lowering for
x87's 80-bit format, and LLVM crashes selecting it.

Only clang's bare-metal driver searches the sysroot on its own, and it
picks that driver for arm64 but not for x86_64, hence spelling out both
paths.
2026-08-12 19:30:26 +02:00
Ole André Vadla Ravnås 17698fb564 Use the SDK as sysroot when building softfloat
Only the roll had one, through the environment, so every other build
looked for the libc beside the compiler and found nothing.
2026-08-04 13:44:56 +02:00
Ole André Vadla Ravnås 5611310e70 Let softfloat link checks resolve the libc
picolibc leaves stdout and the heap bounds to the environment, so every
configure check that touched stdio or malloc failed on those instead of
on what it was checking.
2026-08-04 13:35:19 +02:00
Ole André Vadla Ravnås 64a74a4982 Build the soft-float SDK's libc and runtime
The none-arm64-softfloat flavour has no C library of its own: newlib has
no soft-float build for arm64, so it borrows one assembled by hand. Add
picolibc and compiler-rt as packages instead.

Both are needed before anything else compiles, since the toolchain finds
their headers through --sysroot, so the packages that would otherwise
have no dependencies gain one. Under -mabi=aapcs-soft a double is passed
in x0, and picking up a runtime that expects d0 makes every helper the C
library calls return nonsense without failing.

Bump libffi for the matching x18 fix.
2026-08-03 15:09:26 +02:00
Ole André Vadla Ravnås 75720c9b89 Add a softfloat machine config
Passing floats in general-purpose registers is an ABI break, so it earns
a config rather than a build option. It drags -ffixed-x18 and -fno-pic
along because the first host needing it is the Linux arm64 kernel, which
reserves x18 and whose module loader rejects GOT relocations. newlib's
syscall stubs are dropped: this flavour brings picolibc instead.
2026-07-31 14:21:02 +02:00
Ole André Vadla Ravnås 88cda351c5 Also keep MSVC INCLUDE/LIB in the environment
The per-machine /I and /LIBPATH flags only reach the host compiler. A
native build's build-machine compiler, used for native targets like the
resource compiler, still needs INCLUDE/LIB from the environment, which
spans both machines.
2026-07-16 16:22:04 +02:00
Ole André Vadla Ravnås 638f72c643 Point each MSVC compiler at its own paths
Header and library search paths went into INCLUDE/LIB, which can only
hold one toolchain and thus broke arm64<->x64 cross builds. Emit them
as per-machine /I and /LIBPATH flags, which MSVC searches first.
2026-07-16 13:23:03 +02:00
Ole André Vadla Ravnås da97dbde19 configure: Add --with-apple-min-os flag
Allow overriding the Apple deployment-target floor at configure
time without editing env_apple.py — e.g., to raise macOS to
15+ for the Apple-native gioapple TLS backend.

Pass --with-apple-min-os=PLATFORM=VERSION once per platform to
override (PLATFORM being a key in APPLE_MINIMUM_OS_VERSIONS).
Precedence: explicit os-dash-arch entry > explicit OS entry >
os-dash-arch default > OS default.
2026-04-26 10:12:01 +02:00
Ole André Vadla Ravnås 1d72b53eb1 env: Tolerate linker detection failure on MSVC
When Swift's clang.exe is found by env2mfile on Windows instead of
cl.exe, detect_linker_flavor() invokes it with `-Wl,--version`, which
produces only link.exe's LNK4044 warning and no recognisable version
banner, causing LinkerDetectionError to propagate out of
init_machine_config().

Catch the exception and fall through to the winenv.detect_msvs_tool_path
path, which correctly locates cl.exe/link.exe for the target machine.
2026-04-14 19:02:02 +02:00
Ole André Vadla Ravnås 2df850d900 env: Skip -Wl,-z,relro for Windows as well
As it is not supported/applicable on MinGW toolchains.
2025-08-01 20:19:27 +02:00
Henrik Grimler 813c5fc2bf env_generic: Add another match for lld linker (#15)
If we use LLD with GCC, then `gcc -Wl,--version` outputs something like:

    collect2 version 13.3.0
    [ ... ]
    LLD 18.0.3 (compatible with GNU linkers)

which is not currently matched in env_generic.py. To fix it, look for
the "compatible with GNU linkers" substring as well.
2025-07-14 11:44:04 +02:00
zetier-hg 90a7f7e4f1 Support 'armv6kz-' prefixed toolchains (#12) 2025-07-06 16:24:00 +02:00
Ori Perry a62d71df97 Fix typings for Python < 3.9 (#14) 2025-07-06 16:21:49 +02:00
Ole André Vadla Ravnås 832fea3718 Add preliminary support for machine.os == 'none' 2025-07-05 17:00:41 +02:00
Ole André Vadla Ravnås 5d9edf166c env_generic: Add tuning and FPU flags for armhf
So we leave less to chance with various toolchains.
2025-05-20 22:04:47 +02:00
Ole André Vadla Ravnås 6dd07217f4 env_generic: Do not use Thumb mode on QNX
It's not supported in earlier OS versions.
2025-03-18 20:03:00 +01:00
Ole André Vadla Ravnås 27f2992250 env_generic: Drop dynamic linker flags for arm64be{,ilp32}
The toolchain should already have a sensible default.
2025-03-18 10:50:35 +01:00
Ole André Vadla Ravnås 19e41444ad env_generic: Fix the armbe8 CFLAGS
So they match our toolchain.
2025-03-18 07:25:36 +01:00
Ole André Vadla Ravnås 3c569fadf4 env: Generate Thumb code on 32-bit ARM
For smaller binaries.
2025-03-15 21:21:14 +00:00
WorksButNotTested 4f2bf8ca1b Add support for arm64beilp32 (#10) 2025-03-12 13:39:58 +01:00
WorksButNotTested 0107acaf0b Add support for arm64be (#9) 2025-03-12 08:57:51 +01:00
JunGe-Y 8870e5861b Support non-UTF-8 locales (#5) 2024-11-14 00:28:00 +01:00
Ole André Vadla Ravnås 3474414e02 env_generic: Detect and avoid broken gcc-* tools 2024-04-30 20:07:38 +00:00
Ole André Vadla Ravnås e49618933c env_generic: Add flags used in our MSVS build system
To avoid binary footprint regressions.
2024-04-17 15:55:13 +02:00
Ole André Vadla Ravnås c43f2e0174 winenv: Use the native MSVC toolchain on x86_64
Instead of always using the x86 one.
2024-04-16 23:25:44 +02:00
Ole André Vadla Ravnås 649dc9f722 winenv: Remove msvc_platform_from_arch()
Replacing it with MachineSpec.msvc_platform where it's needed.
2024-04-16 22:38:55 +02:00
Ole André Vadla Ravnås 9466dc1c3b machine_spec: Fold vscrt into config
To simplify things.
2024-04-16 12:12:47 +02:00
Ole André Vadla Ravnås 885cc7adf0 env: Do not generate MSVC wrapper scripts for now
Meson makes some assumptions that require further investigation.
2024-04-06 00:17:19 +02:00
Ole André Vadla Ravnås c01b048c86 env: Generate wrapper scripts for MSVC tools
To ensure that include and library paths don't get mixed up when
cross-compiling.
2024-04-05 23:58:47 +02:00
Ole André Vadla Ravnås 16856ab533 env_generic: Ensure all binary entries are absolute
For consistency and to avoid depending on the PATH not changing.
2024-04-05 14:44:08 +02:00
Ole André Vadla Ravnås b6bd0f2f60 env: Revive support for FRIDA_QEMU_SYSROOT
Which is used to define an appropriate exe_wrapper in the machine file.
2024-04-05 14:44:08 +02:00
Ole André Vadla Ravnås b235c1c789 env: Tweak order of classes and constants 2024-04-05 10:58:42 +02:00
Ole André Vadla Ravnås 7d9286bf13 env: Lift envvar build vs host splitting to the top
Now that we need this for env_apple and env_android, too.
2024-04-04 21:36:50 +00:00
Ole André Vadla Ravnås bb51840100 env: Pass environment into generate_machine_files()
So callers have more control without mutating global state.
2024-04-04 21:36:50 +00:00
Ole André Vadla Ravnås 83e7383ebf env_generic: Try -m32 as a last resort on Linux
When cross-compiling for 32-bit Linux on a 64-bit Linux system.
2024-03-27 13:40:11 +01:00
Ole André Vadla Ravnås c99f890e21 env_generic: Refactor resolving of GCC binaries 2024-03-27 13:36:35 +01:00
Ole André Vadla Ravnås 3b17fbb2fd env_generic: Add some more type annotations 2024-03-27 13:34:41 +01:00
Ole André Vadla Ravnås b9400305ec Rename “native_machine” ⇒ “build_machine”
For consistency with Meson's naming conventions.
2024-03-20 22:24:15 +01:00
Ole André Vadla Ravnås 5212dff396 env: Use canonical tool names for ar and friends 2024-03-14 12:17:56 +01:00