aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChains/OpenBSD.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-22Adding Loongarch64 to OpenBSD parts (#149737)Slava "nerfur" Voronzoff1-1/+1
Adding Loongarch64 to OpenBSD parts
2025-06-06[Driver] Move CommonArgs to a location visible by the Frontend Drivers (#142800)Cameron McInally1-1/+1
This patch moves the CommonArgs utilities into a location visible by the Frontend Drivers, so that the Frontend Drivers may share option parsing code with the Compiler Driver. This is useful when the Frontend Drivers would like to verify that their incoming options are well-formed and also not reinvent the option parsing wheel. We already see code in the Clang/Flang Drivers that is parsing and verifying its incoming options. E.g. OPT_ffp_contract. This option is parsed in the Compiler Driver, Clang Driver, and Flang Driver, all with slightly different parsing code. It would be nice if the Frontend Drivers were not required to duplicate this Compiler Driver code. That way there is no/low maintenance burden on keeping all these parsing functions in sync. Along those lines, the Frontend Drivers will now have a useful mechanism to verify their incoming options are well-formed. Currently, the Frontend Drivers trust that the Compiler Driver is not passing back junk in some cases. The Language Drivers may even accept junk with no error at all. E.g.: `clang -cc1 -mprefer-vector-width=junk test.c' With this patch, we'll now be able to tighten up incomming options to the Frontend drivers in a lightweight way. --------- Co-authored-by: Cameron McInally <cmcinally@nvidia.com> Co-authored-by: Shafik Yaghmour <shafik.yaghmour@intel.com>
2025-05-23[Driver][LTO] Move common code for LTO to addLTOOptions() (#74178)Brad Smith1-12/+2
2025-04-03[flang-rt] Pass the whole path of libflang_rt.runtime.a to linker on AIX and ↵Daniel Chen1-6/+6
LoP (#131041) This PR is to improve the driver code to build `flang-rt` path by re-using the logic and code of `compiler-rt`. 1. Moved `addFortranRuntimeLibraryPath` and `addFortranRuntimeLibs` to `ToolChain.h` and made them virtual so that they can be overridden if customization is needed. The current implementation of those two procedures is moved to `ToolChain.cpp` as the base implementation to default to. 2. Both AIX and PPCLinux now override `addFortranRuntimeLibs`. The overriding function of `addFortranRuntimeLibs` for both AIX and PPCLinux calls `getCompilerRTArgString` => `getCompilerRT` => `buildCompilerRTBasename` to get the path to `flang-rt`. This code handles `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` setting. As shown in `PPCLinux.cpp`, `FT_static` is the default. If not found, it will search and build for `FT_shared`. To differentiate `flang-rt` from `clang-rt`, a boolean flag `IsFortran` is passed to the chain of functions in order to reach `buildCompilerRTBasename`.
2024-12-15Revert "[Driver] Cache SanitizerArgs (NFC) (#119442)"Nico Weber1-4/+2
This reverts commit bae383ba6b53b0d8257c83f99ceecdd751d0a378. Prerequisite to reverting #119071.
2024-12-12[Driver] Cache SanitizerArgs (NFC) (#119442)Aaron Puchert1-2/+4
The name getSanitizerArgs seems to mislead callers that this is a cheap function, but it extracts the SanitizerArgs each time it is called. So we try to reuse it a bit more.
2024-09-17[flang][Driver] Support -nostdlib and -nodefaultlibs (#108868)Tarun Prabhu1-1/+2
This partially addresses some requests in #89888
2024-05-15[clang] Don't assume location of compiler-rt for OpenBSD (#92183)John Ericson1-1/+2
If the `/usr/lib/...` path where compiler-rt is conventionally installed on OpenBSD does not exist, fall back to the regular logic to find it. This is a minimal change to allow OpenBSD cross compilation from a toolchain that doesn't adopt all of OpenBSD's monorepo's conventions.
2024-04-01[OpenMP] Use loaded offloading toolchains to add libraries (#87108)Joseph Huber1-1/+1
Summary: We want to pass these GPU libraries by default if a certain offloading toolchain is loaded for OpenMP. Previously I parsed this from the arguments because it's only available in the compilation. This doesn't really work for `native` and it's extra effort, so this patch just passes in the `Compilation` as an extr argument and uses that. Tests should be unaffected.
2024-03-04[Driver][RISCV] Forward --no-relax option to linker for RISC-V on *BS… ↵Brad Smith1-1/+5
(#83216) …D, Fuchsia and Haiku Based on https://github.com/llvm/llvm-project/pull/76432
2024-03-02[Driver] Remove duplicate -r flag usage when linking (#82715)Brad Smith1-2/+2
Bug #82010
2024-01-19[Driver] Use SmallString::operator std::string (NFC)Kazu Hirata1-2/+2
2023-11-28[flang][Driver] Let the linker fail on multiple definitions of main() (#73124)Michael Klemm1-1/+1
The flang driver was silently ignoring the `main()` function in `Fortran_main.a` for entry into the Fortran program unit if an external `main()` as supplied (e.g., via cross-language linkage with Fortran and C/C++). This PR fixes this by making sure that the linker always pulls in the `main()` definition from `Fortran_main.a` and consequently fails due to multiple definitions of the same symbol if another object file also has a definition of `main()`.
2023-11-23[flang] Add runtimes using --dependent-lib on MSVC targets (#72519)David Truby1-1/+1
This patch uses the added --dependent-lib support to add the relevant runtimes on MSVC targets as `/DEFAULTLIB:` sections in the object file rather than on the link line. This should help CMake support for flang on Windows. Fixes #63741 Fixes #68017
2023-11-20[Driver] Make ELF -nopie specific to OpenBSD (#72578)Fangrui Song1-1/+1
-no-pie[1]/-nopie is rarely used and among the rare uses almost everwhere uses -no-pie, since GCC does not recognize -nopie. However, OpenBSD seems to use -nopie. Therefore, make -nopie specific to OpenBSD to prevent newer ToolChains (Solaris, SerenityOS) from cargo culting and copying -nopie. [1]: https://reviews.llvm.org/D35462
2023-11-15[Driver][NFC] A bit more const for OpenBSD and DragonFlyBrad Smith1-7/+7
2023-11-13[Driver][OpenBSD] Enable kernel address sanitizer on amd64Brad Smith1-4/+3
2023-11-13[Driver] Add LTO support for Haiku and OpenBSD (#72047)Brad Smith1-0/+14
2023-11-10[flang][windows] Add option to link against specific MSVC CRT (#70833)David Truby1-1/+1
Currently flang's runtime libraries are only built for the specific CRT that LLVM itself was built against. This patch adds the cmake logic for building a separate runtime for each CRT configuration and adds a flag for selecting a CRT configuration to link against.
2023-11-01[Driver] Silence stdlib warning when linking C on *BSD / Solaris / Haiku ↵Brad Smith1-0/+3
(#70434) Same as 12b87f6ef720080fab1e2d48ca2d8c5ba478ee5d and the addition to Gnu.
2023-10-27[Driver][NFC] Fix a typo in the function nameBrad Smith1-1/+1
2023-10-27[Driver] Link Flang runtime on FreeBSD, NetBSD, OpenBSD, DragonFly and Haiku ↵Brad Smith1-0/+14
(#69817)
2023-10-26[Driver][NFC] Make use of auto (#70400)Brad Smith1-4/+2
2023-10-26[Driver] Clean up unused architecture related bits for *BSD's (#69809)Brad Smith1-2/+1
- FreeBSD removed big-endian arm with 12.0. - OpenBSD never had big-endian arm support. I added it just in case, but it has never been used. - Remove sparcel bits. It was sprinkled in a few places but it will never be a thing. - Remove 32-bit sparc bits for FreeBSD. FreeBSD has never had 32-bit sparc support. - Remove sparc64 IAS test as support was enabled across the board awhile ago.
2023-10-20[Driver] Corrections for linker flags passed with relocatable linking on ↵Brad Smith1-3/+3
OpenBSD (#67254) The entry point symbol handling matches our GCC link spec.. ```%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}}``` Remove usage of -Bdynamic as it is the default for the linker anyway. Came up in discussion here https://github.com/llvm/llvm-project/pull/65644
2023-10-15[Driver] Don't pass -Z to ld for ELF platforms (#69120)Fangrui Song1-3/+2
-Z is an Apple ld64 option. ELF linkers don't recognize -Z, except OpenBSD which patched GNU ld to add -Z for zmagic (seems unused) > -Z Produce 'Standard' executables, disables Writable XOR Executable features in resulting binaries. Some `ToolChain`s have -Z due to copy-and-paste mistakes.
2023-10-10[Driver] Rename AddAllArgs (initialization list overload) to addAllArgsFangrui Song1-1/+1
Most ArgList member functions use the modern functionName style while some like AddAllArgs use the legacy FunctionName style. These uses are mostly linker options which have been modified recently to fix duplicate -e issues, so just update these call sites.
2023-09-25[Driver] Move assertion check before checking Output.isFilename (#67210)Brad Smith1-2/+1
2023-08-28[Driver] Improve legibility of ld -z options on SolarisRainer Orth1-2/+2
Following the lead of the Linux code, this patch passes the `ld -z` options as two separate args on Solaris, improving legibility. For lack of a variadic `std::push_back`, `getAsNeededOption` had to be changed to `addAsNeededOption`, matching other `add*Options` functions, changing callers accordingly. The additional args are also used in a WIP revision of the Solaris GNU ld patch D85309 <https://reviews.llvm.org/D85309>, which will allow runtime selection of the linker to use. Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`. Differential Revision: https://reviews.llvm.org/D158955
2023-07-07[Driver] Remove duplicate -eFangrui Song1-3/+3
-e has the LinkerInput flag (commit fcf8ada18f9cfb1261262e4b0399ae9ab40451f8) and is rendered by AddLinkerInputs. We should remove duplicate rendering (e.g., `Args.AddAllArgs(CmdArgs, options::OPT_e)`).
2023-02-26[Driver][OpenBSD] Simplify command-line option handling. NFCBrad Smith1-16/+19
2022-09-20Refactor unwind table driver interface to expose default level. NFC.Tim Northover1-7/+8
2022-07-22[Clang][Driver] Fix include paths for `--sysroot /` on OpenBSD/FreeBSDEgor Zhdan1-3/+4
This is the same change as https://reviews.llvm.org/D126289, but applied for OpenBSD & FreeBSD. Differential Revision: https://reviews.llvm.org/D129654
2022-07-19[clang] Add a new flag -fexperimental-library to enable experimental library ↵Louis Dionne1-0/+2
features Based on the discussion at [1], this patch adds a Clang flag called -fexperimental-library that controls whether experimental library features are provided in libc++. In essence, it links against the experimental static archive provided by libc++ and defines a feature that can be picked up by libc++ to enable experimental features. This ensures that users don't start depending on experimental (and hence unstable) features unknowingly. [1]: https://discourse.llvm.org/t/rfc-a-compiler-flag-to-enable-experimental-unstable-language-and-library-features Differential Revision: https://reviews.llvm.org/D121141
2022-07-16[Driver] Don't passs --dynamic-linker in -r modeBrad Smith1-1/+1
No behavior change as GNU ld/gold/ld.lld ignore --dynamic-linker in -r mode. This change makes the intention clearer as we already suppress --dynamic-linker for -shared, -static, and -static-pie. Reviewed by: MaskRay, phosek Differential Revision: https://reviews.llvm.org/D129714
2022-06-26[Driver] Use Component in OpenBSD::getCompilerRT to find librariesGreg Steuck1-5/+15
Clang uses runtime libraries for some advanced features like sanitizers. Different systems have different preferences about file placement. OpenBSD with this change will use this name for ASan: /usr/lib/clang/15.0.0/lib/libclang_rt.asan.a Already committed to OpenBSD repository then amended to cover the case of development tree. Differential Revision: https://reviews.llvm.org/D109051
2022-06-18[Driver][OpenBSD] Use Arch reference instead of getArch(). NFCBrad Smith1-3/+4
2022-06-18[Driver] Pass -X to ld for riscv64-openbsdBrad Smith1-0/+3
Noticing D127826, add support for OpenBSD which uses lld on riscv64. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D128109
2022-03-09[Driver][OpenBSD] Disable unwind tables on ArmBrad Smith1-0/+9
Arm is not quite ready for unwinding yet.
2022-02-21[Driver][OpenBSD] Pass sysroot to the linkerBrad Smith1-0/+3
2022-02-07[Driver][OpenBSD] -r: imply -nostdlib like GCCBrad Smith1-3/+6
Similar to D116843 for Gnu.cpp Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D119071
2021-10-20[Driver][OpenBSD] Some improvements to the external assembler handlingBrad Smith1-6/+19
- Pass CPU variant for ARM - Pass MIPS CPU in addition to the ABI
2021-10-09[Driver][OpenBSD] Use ToolChain reference instead of getToolChain().Frederic Cambus1-10/+13
Differential Revision: https://reviews.llvm.org/D111462
2021-09-03Support linking against OpenMP runtime on OpenBSD.Brad Smith1-0/+5
2021-09-03[clang] Allow the OpenBSD driver to link the libclang_rt.profile library.Frederic Cambus1-0/+2
Differential Revision: https://reviews.llvm.org/D109244
2021-09-02[clang-cl] Emit nicer warning on unknown /arch: argumentsNico Weber1-2/+4
Now prints the list of known archs. This requires plumbing a Driver arg through a few functions. Also add two more convenience insert() overlods to StringMap. Differential Revision: https://reviews.llvm.org/D109105
2021-02-20[clang][Driver][OpenBSD] libcxx also requires pthreadBrad Smith1-0/+1
2020-10-08[Driver] Add output file to properties of CommandSerge Pavlov1-4/+6
Object of class `Command` contains various properties of a command to execute, but output file was missed from them. This change adds this property. It is required for reporting consumed time and memory implemented in D78903 and may be used in other cases too. Differential Revision: https://reviews.llvm.org/D78902
2020-08-29Remove OpenBSD/sparc supportBrad Smith1-9/+0
2020-08-27Default to -fuse-init-array on OpenBSD.Brad Smith1-9/+0