summaryrefslogtreecommitdiff
path: root/mesonbuild/linkers/linkers.py
AgeCommit message (Collapse)Author
2025-11-23compilers: forward gen_vs_module_defs_args to linkerPaolo Bonzini
This adds support for DEF files to rust and removes some hasattr duck typing. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-23linkers: add gen_vs_module_defs_argsPaolo Bonzini
.def files are a linker concept, and they should not be shoehorned into the Compiler. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-19compilers: Remove Environment parameter from CLikeCompiler.gen_dynamic_link_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_option_link_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.has_multi_argumentsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.build_rpath_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.thread_flagsDylan Baker
Same logic as the openmp flags
2025-11-19compilers: Remove Environment parameter from Compiler.openmp_flagsDylan Baker
I've done the compile and link flags in one commit since they're so closely related
2025-11-19compilers: Remove Environment parameter from Compiler.get_soname_argsDylan Baker
2025-11-19linkers: Store a reference to the Environment in the DynamicLinkerDylan Baker
For the same reason that the StaticLinker needs this, we need it in the DynamicLinker as well.
2025-11-19linkers: Store a reference to the Environment in the StaticLinkerDylan Baker
There are a number of places where we treat StaticLinker and Compiler as polymorphic, as such the StaticLinker cannot need extra parameters.
2025-11-14Add `os2_emxomf' option to generate OMF files on OS/2KO Myung-Hun
1. Generate OMF objs with `-Zomf' compiler flags 2. Generate OMF libs with `.lib' suffix using `emxomfar' as a librarian
2025-11-14OS/2 linker does not support a thin archiveKO Myung-Hun
2025-11-14Add OS2 dynamic linker supportKO Myung-Hun
2025-11-12linkers: add -no_warn_duplicate_libraries when testing for arguments to Apple ldPaolo Bonzini
No other linker warns for duplicate libraries, and (especially with rustc) specifying --fatal-warnings may cause the warnings to trigger and a wrong result from has_multi_link_arguments. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29compilers: add Microchip XC32 compilerLiza Chevalier
The Microchip XC32 compiler is a GCC-based compiler implemented using existing GNU compiler classes. As the XC32 version and GCC version do not match mixins have been implemented to override versions used in versions checks where applicable.
2025-08-25linkers: Fix dsymutil being unable to symbolicate binaries with LTOL. E. Segovia
According to https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-flto, the -object_path_lto flag is needed to preserve the intermediate object files.
2025-08-01call determine_rpath_dirs only when linker requires itCharles Brunet
2025-07-18linkers: add extra_paths to build_rpath_argsPaolo Bonzini
Allow adding extra directories to the rpath. Rust needs this when Rustup is in use. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-05Add ELD linkerKushal Pal
ELD is Qualcomm's open-source embedded linker. https://github.com/qualcomm/eld Signed-off-by: Kushal Pal <kushpal@qti.qualcomm.com>
2025-04-16linkers: fix regression when using lld after iOS changesEli Schwartz
``` $ LDFLAGS="-fuse-ld=lld" meson setup builddir/ [...] linker = lld_cls( compiler, for_machine, comp_class.LINKER_PREFIX, override, system=system, version=v) TypeError: LLVMDynamicLinker.__init__() got an unexpected keyword argument 'system' ``` Fixes regression in commit cece1a7e9992a3bbcc35f90777ba22ba9d62b538. We pass system=system to the linker construction, which worked fine for Apple LLVM LD64 as that inherited `__init__` from DynamicLinker. But non-Apple LLD had an overridden `__init__` which wasn't adapted. Even if it is thrown away and never used, since LLVM isn't an Apple linker, we still need to obey the argument contract.
2025-04-16linkers: apple: fix shared module argsPaolo Bonzini
iOS should not use -undefined,dynamic_lookup; whereas macOS should revert from -dynamiclib to -bundle, as was the case before commit cfb5a48e0 ("linkers: darwin: do not use -bundle for shared_modules", 2025-03-24), because Postgres wants to use -bundle_loader and that is only possible together with -bundle. Co-authored-by: Russell Keith-Magee <russell@keith-magee.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-16linkers: pass system to DynamicLinker.__init__ for Darwin linkersPaolo Bonzini
Apple linkers need to use different arguments on macOS and iOS-like platforms. Pass the system to the constructor so that it can be examined. Co-authored-by: Russell Keith-Magee <russell@keith-magee.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-14Fix two shared objects in archive for AIX.Aditya Vidyadhar Kamath
In AIX, when we use ar -q to archive then if there is a shared object already existing with the same name a duplicate one is created if one tries to archive again. Meson archives shared library during build time and relinks again during install time. At this stage when shared object is again made and archived again, creating two shared objects in the archive. When we use "ar -rs" then we ensure it is only one. Reference: https://www.ibm.com/docs/en/aix/7.1?topic=ar-command This patch is a fix to the same. Before patch output: rwxr-xr-x 0/0 5018 Apr 14 05:57 2025 libmylib.so rwxr-xr-x 0/0 5018 Apr 14 05:58 2025 libmylib.so After patch output: rwxr-xr-x 0/0 5018 Apr 14 07:23 2025 libmylib.so
2025-04-13linkers: fix Apple ld -install_name with custom suffixPaolo Bonzini
Use the custom suffix instead of .dylib, so that executables that are linked to a custom-suffix library can be ran from the build tree. Fixes: #14470
2025-04-02compilers: introduce get_exe() and get_exe_args()Paolo Bonzini
This will be used by rustdoc tests because the Test objects takes a single string for the command and everything else goes in the args. But apart from this, the need to split the executable from the arguments is common so create new methods to do it. While at it, fix brokenness in the handling of the zig compiler, which is checking against "zig" but failing to detect e.g. "/usr/bin/zig". Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-03-24linkers: darwin: do not use -bundle for shared_modulesPaolo Bonzini
Both dynamic libraries and bundles these days can be dynamically loaded using the dl APIs (e.g. dlopen, dlclose). It is not possible to include bundles on a linker command line as if they were shared libraries, but that's pretty much the only difference. However, bundles fail the Apple verification for iOS: 2025-02-10 13:54:09.095 ERROR: Validation failed (409) The binary is invalid. The executable 'Runner.app/Frameworks/numpy._core._operand_flag_tests.framework/numpy._core._operand_flag_tests' has type 'BUNDLE' that is not valid. Only 'EXECUTE' is permitted. 2025-02-10 13:54:09.096 ERROR: Validation failed (409) Missing load commands. The executable at 'Runner.app/Frameworks/numpy._core._operand_flag_tests.framework' does not have the necessary load commands. Try rebuilding the app with the latest Xcode version. If you are using third party development tools, contact the provider. So switch to -dynamiclib for shared modules as well. Fixes: #14240
2025-03-11linkers: revert a binutils bug workaround, sort ofEli Schwartz
More specifically, the bug had been fixed shortly before we implemented this workaround. It's documented as only necessary for the binutils brand specifically, and was fixed upstream in 2.28. We can avoid producing these arguments at all on newer (post-2016) versions of binutils, so gate this behind a version check. This can significantly reduce the size of compiler command lines in some cases, as it encodes the full build directory. It also helps that one person who decides to put commas into their build directory name (which `-Wl,...` interprets as multiple arguments, rather than a single directory string). Bug: https://github.com/mesonbuild/meson/pull/1898 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20535 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16936
2025-03-09compilers: convert `b_sanitize` to a free-form array optionPatrick Steinhardt
In the preceding commit we have started to perform compiler checks for the value of `b_sanitize`, which allows us to detect sanitizers that aren't supported by the compiler toolchain. But we haven't yet loosened the option itself to accept arbitrary values, so until now it's still only possible to pass sanitizer combinations known by Meson, which is quite restrictive. Lift that restriction by adapting the `b_sanitize` option to become a free-form array. Like this, users can pass whatever combination of comma-separated sanitizers to Meson, which will then figure out whether that combination is supported via the compiler checks. This lifts a couple of restrictions and makes the supporting infrastructure way more future proof. A couple of notes regarding backwards compatibility: - All previous values of `b_sanitize` will remain valid as the syntax for free-form array values and valid combo choices is the same. We also treat 'none' specially so that we know to convert it into an empty array. - Even though the option has been converted into a free-form array, callers of `get_option('b_sanitize')` continue to get a string as value. We may eventually want to introduce a kwarg to alter this behaviour, but for now it is expected to be good enough for most use cases. Fixes #8283 Fixes #7761 Fixes #5154 Fixes #1582 Co-authored-by: Dylan Baker <dylan@pnwbakers.com> Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-02-13Make all Meson level options overridable per subproject.Jussi Pakkanen
2025-01-20linkers: fix rpath padding calculation for non-asciiEli Schwartz
rpaths are calculated in bytes, and that's also how depfixer processes them. We need to ensure that the ascii padding we use (bytes == unicode) is the correct offset for the install rpath - build rpath (both specified in unicode which then gets converted to bytes). In the event of a unicode install_rpath, we can get into a situation where the install rpath is longer than the padding, since we assumed that the install_rpath was shorter than it actually is -- because we counted the length in characters instead of the length in bytes. This then broke installation for people who e.g. install into a prefix inside their home directory, when their home directory contains multibyte unicode characters. Bug: https://gitlab.gnome.org/GNOME/gnome-builder/-/issues/2280
2025-01-08First draft version of Tasking MIL linking with b_lto and prelinkinggerioldman
2025-01-08Add TASKING compiler supportgerioldman
2024-10-30Merge pull request #13681 from EngJay/13678-fix-ti-cgt-supportJussi Pakkanen
Fix TI C2000 support
2024-10-18add getter for id so linker can be identifiedJason Scott
2024-09-29metrowerks: Whine when trying to build a shared librarymid-kid
Also cleaned up redundant functions in the subclass.
2024-09-24linkers: Disable -rpath-link with ld.zigccTristan Ross
Zig issue https://github.com/ziglang/zig/issues/18713
2024-09-24linkers: basic support for the 'zig cc' linkerAndrei Alexeyev
2024-08-20linkers: skip -export_dynamic flag before MacOS 10.7Wolfgang Walther
The flag was only introduced in ld 224.1, as mentioned in the initial PR #13291. Resolves #13543
2024-08-09linkers: fix LLD linker response file handlingBenoit Pierre
Correct base classes so GNU-like linkers all default to supporting response files.
2024-08-08Fix compiling ObjC/ObjC++ on Windows/MinGWJonathan Schleifer
Co-Authored-By: L. E. Segovia <amy@amyspark.me>
2024-08-07linkers: Fix RSP syntax for linkers invoked with clangKacper Michajłow
Fixes: #8981 Fixes: 2be074b1d445fcd30535bcf7518f8ce0738bcbf3 Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2024-06-29linkers: Fix AppleDynamicLinker not returning any rpaths to removePiotr Brzeziński
Fixes regression from commit 78e9009ff9d36925e04f329f9082841002ddd848. The above commit relied on rpath_dirs_to_remove being present and correctly filled, which was never the case for the AppleDynamicLinker. The result was that all the build-dir-only RPATHs were being carried over to the installed files. This commit implements returning the list of RPATHs to remove in AppleDynamicLinker, doing pretty much the same thing as what's in the GnuLikeDynamicLinkerMixin. Thanks to that, depfixer now correctly removes build-time Meson-created RPATHs, as it used to before 1.4.1.
2024-06-26compilers: pass Environment to openmp_flagsDylan Baker
This will be needed by the Apple compiler
2024-06-05Add -export_dynamic flag for AppleDynamicLinkerWolfgang Walther
The apple linker uses -export_dynamic instead of --export-dynamic [1]. This should be set when setting export_dynamic: true. Resolves #13290 [1]: https://opensource.apple.com/source/ld64/ld64-609/doc/man/man1/ld.1.auto.html
2024-05-15Merge pull request #11421 from mon/ti-armclangJussi Pakkanen
Basic support for TI Arm Clang toolchain
2024-04-05Merge pull request #12144 from amyspark/fix-msvc-clangcl-linker-flag-detectionJussi Pakkanen
linkers: Fix detection of link arguments to Clang(-cl) + MSVC
2024-03-13Basic support for TI ARM-CLANG toolchainWilliam Toohey
2024-03-12Added support for Texas Instruments C6000 compiler.Petr Machacek
2024-03-03compilers: only wrap multiple input libraries with start/end groupEli Schwartz
When only a single input file shows up in an arglist, it makes no sense to inject `-W,--start-group -lone -Wl,--end-group`, since there is nothing being grouped together. It's just longer command lines for nothing.