summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/back
AgeCommit message (Collapse)AuthorLines
2024-11-03Reduce dependence on the target namebjorn3-20/+9
The target name can be anything with custom target specs. Matching on fields inside the target spec is much more robust than matching on the target name.
2024-11-02Rename target triple to target tuple in many places in the compilerNoratrieb-3/+3
This changes the naming to the new naming, used by `--print target-tuple`. It does not change all locations, but many.
2024-11-02Rollup merge of #131037 - madsmtm:move-llvm-target-versioning, r=petrochenkovMatthias Krüger-1/+2
Move versioned Apple LLVM targets from `rustc_target` to `rustc_codegen_ssa` Fully specified LLVM targets contain the OS version on macOS/iOS/tvOS/watchOS/visionOS, and this version depends on the deployment target environment variables like `MACOSX_DEPLOYMENT_TARGET`, `IPHONEOS_DEPLOYMENT_TARGET` etc. We would like to move this to later in the compilation pipeline, both because it feels impure to access environment variables when fetching target information, but mostly because we need access to more information from https://github.com/rust-lang/rust/pull/130883 to do https://github.com/rust-lang/rust/issues/118204. See also https://github.com/rust-lang/rust/pull/129342#issuecomment-2335156119 for some discussion. The first and second commit does the actual refactor, it should be a non-functional change, the third commit adds diagnostics for invalid deployment targets, which are now possible to do because we have access to the session. Tested with the same commands as in https://github.com/rust-lang/rust/pull/130435. r? ``````@petrochenkov``````
2024-11-01Move versioned LLVM target creation to rustc_codegen_ssaMads Marquart-1/+2
The OS version depends on the deployment target environment variables, the access of which we want to move to later in the compilation pipeline that has access to more information, for example `env_depinfo`.
2024-10-31Remove support for `-Zprofile` (gcov-style coverage instrumentation)Zalathar-1/+0
2024-10-30Consistently use safe wrapper function `set_section`Zalathar-10/+9
2024-10-29Rollup merge of #132319 - Zalathar:add-module-flag, r=jieyouxuMatthias Krüger-18/+3
cg_llvm: Clean up FFI calls for setting module flags This is a combination of several inter-related changes to how module flags are set: - Remove some unnecessary code for setting an `"LTOPostLink"` flag, which has been obsolete since LLVM 17. - Define our own enum instead of relying on enum values defined by LLVM's unstable C++ API. - Use safe wrapper functions to set module flags, instead of direct `unsafe` calls. - Consistently pass pointer/length strings instead of C strings. - Remove or shrink some `unsafe` blocks.
2024-10-29Don't set unnecessary module flag "LTOPostLink"Zalathar-18/+3
This module flag was an internal detail of LLVM's optimization passes, and all code involving it was removed in LLVM 17. <https://github.com/llvm/llvm-project/commit/200cc952a28a73687ba24d5334415df6332f2d5b>
2024-10-29Rollup merge of #132216 - klensy:c_uint, r=cuviperJubilee-2/+2
correct LLVMRustCreateThinLTOData arg types `LLVMRustCreateThinLTOData` defined in rust as ```rust pub fn LLVMRustCreateThinLTOData( Modules: *const ThinLTOModule, NumModules: c_uint, PreservedSymbols: *const *const c_char, PreservedSymbolsLen: c_uint, ) -> Option<&'static mut ThinLTOData>; ``` but in cpp as ```cpp extern "C" LLVMRustThinLTOData * LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules, const char **preserved_symbols, int num_symbols) { ``` (note `c_unit` vs `int` types). Let it be actually `size_t`. Also fixes return type of `LLVMRustDIBuilderCreateOpLLVMFragment` to uint64_t as other similar functions around, which should be correct, i assume.
2024-10-29Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillotJubilee-1/+1
compiler: apply clippy::clone_on_ref_ptr for CI Apply lint https://rust-lang.github.io/rust-clippy/master/index.html#/clone_on_ref_ptr for compiler, also see https://github.com/rust-lang/rust/pull/131225#discussion_r1790109443. Some Arc's can be misplaced with Lrc's, sorry. https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/enable.20more.20clippy.20lints.20for.20compiler.20.28and.5Cor.20std.29
2024-10-29correct LLVMRustCreateThinLTOData arg typesklensy-2/+2
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-1/+1
2024-10-28Use a type-safe helper to cast `&str` and `&[u8]` to `*const c_char`Zalathar-6/+8
2024-10-26Use safe wrappers `get_linkage` and `set_linkage`Zalathar-4/+4
2024-09-26Use `&raw` in the compilerJosh Stone-1/+1
Like #130865 did for the standard library, we can use `&raw` in the compiler now that stage0 supports it. Also like the other issue, I did not make any doc or test changes at this time.
2024-09-24Dogfood `feature(file_buffered)`Josh Stone-4/+3
2024-09-23Auto merge of #130724 - compiler-errors:bump, r=Mark-Simulacrumbors-11/+11
Bump stage0 to beta-2024-09-22 and rustfmt to nightly-2024-09-22 I'm doing this to apply the changes to version sorting (https://github.com/rust-lang/rustfmt/pull/6284) that have occurred since rustfmt last upgraded (and a few other miscellaneous changes, like changes to expression overflowing: https://github.com/rust-lang/rustfmt/pull/6260). Eagerly updating rustfmt and formatting-the-world will ideally move some of the pressure off of the beta bump which will happen at the beginning of the next release cycle. You can verify this is correct by checking out the changes, reverting the last commit, reapplying them, and diffing the changes: ``` git fetch git@github.com:compiler-errors/rust.git bump git checkout -b bump FETCH_HEAD git reset --hard HEAD~5 ./x.py fmt --all git diff FETCH_HEAD # ignore the changes to stage0, and rustfmt.toml, # and test file changes in rustdoc-js-std, run-make. ``` Or just take my word for it? Up to the reviewer. r? release
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-11/+11
2024-09-21Call module_name_to_str instead of just unwrappingBen Kimock-1/+1
2024-09-19Reformat some comments.Nicholas Nethercote-12/+15
So they are less than 100 chars.
2024-09-19Reduce repetition in `target_is_apple`.Nicholas Nethercote-5/+6
2024-09-19Streamline `report_inline_asm`.Nicholas Nethercote-8/+7
By using `use`.
2024-09-19Rename a parameter.Nicholas Nethercote-2/+2
This seems to be a typo. `singletree` doesn't make sense, and everywhere else it is `singlethread`.
2024-09-15Rollup merge of #129897 - RalfJung:soft-float-ignored, r=UrgauMatthias Krüger-1/+7
deprecate -Csoft-float because it is unsound (and not fixable) See https://github.com/rust-lang/rust/issues/129893 for details. The general sentiment there seems to be that this flag has no use and sound alternatives exist, so let's add this warning and see if anyone out there disagrees. Also show a different warning on targets where it does nothing (as documented since https://github.com/rust-lang/rust/pull/36261): it seems to correspond to `-mfloat-abi` in GCC/clang, which is an ARM-specific option. To be really sure it does nothing, only forward the flag to LLVM for eabihf targets. This should not change behavior but makes me sleep better ;)
2024-09-11Simplify some nested if statementsMichael Goulet-5/+3
2024-09-09Remove `serialized_bitcode` from `LtoModuleCodegen`.Nicholas Nethercote-6/+2
It's unused.
2024-09-03deprecate -Csoft-float because it is unsound (and not fixable)Ralf Jung-1/+7
2024-08-29Rollup merge of #128970 - DianQK:lint-llvm-ir, r=nikicGuillaume Gomez-0/+1
Add `-Zlint-llvm-ir` This flag is similar to `-Zverify-llvm-ir` and allows us to lint the generated IR. r? compiler
2024-08-29Add `-Zlint-llvm-ir`DianQK-0/+1
2024-08-27Rollup merge of #126013 - nnethercote:unreachable_pub, r=UrgauMatthias Krüger-21/+19
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal. There are plenty more crates to do but this seems like enough for a first PR. r? `@compiler-errors`
2024-08-20Avoid extra `cast()`s after `CStr::as_ptr()`Josh Stone-5/+5
These used to be `&str` literals that did need a pointer cast, but that became a no-op after switching to `c""` literals in #118566.
2024-08-17Always use ar_archive_writer for import libsChris Denton-91/+3
2024-08-16Add `warn(unreachable_pub)` to `rustc_codegen_llvm`.Nicholas Nethercote-21/+19
2024-08-14Unconditionally use the LLVM symbol readerbjorn3-22/+0
This may fix a linker error on MSVC
2024-08-11Fix review comments and other improvementsbjorn3-2/+2
2024-08-10Add fixme for removing LlvmArchiveBuilder in the futurebjorn3-0/+4
2024-08-10Use ArArchiveBuilder with the LLVM backend toobjorn3-3/+1
All regressions that were blocking usage of ArArchiveBuilder should now be fixed.
2024-08-07Rollup merge of #128221 - calebzulawski:implied-target-features, r=AmanieuMatthias Krüger-2/+5
Add implied target features to target_feature attribute See [zulip](https://rust-lang.zulipchat.com/#narrow/stream/208962-t-libs.2Fstdarch/topic/Why.20would.20target-feature.20include.20implied.20features.3F) for some context. Adds implied target features, e.g. `#[target_feature(enable = "avx2")]` acts like `#[target_feature(enable = "avx2,avx,sse4.2,sse4.1...")]`. Fixes #128125, fixes #128426 The implied feature sets are taken from [the rust reference](https://doc.rust-lang.org/reference/attributes/codegen.html?highlight=target-fea#x86-or-x86_64), there are certainly more features and targets to add. Please feel free to reassign this to whoever should review it. r? ``@Amanieu``
2024-08-07Rollup merge of #128206 - bjorn3:import_lib_writing_refactor, r=jieyouxuGuillaume Gomez-154/+19
Make create_dll_import_lib easier to implement This will make it easier to implement raw-dylib support in cg_clif and cg_gcc. This PR doesn't yet include an create_dll_import_lib implementation for cg_clif as I need to correctly implement dllimport in cg_clif first before raw-dylib can work at all with cg_clif. Required for https://github.com/rust-lang/rustc_codegen_cranelift/issues/1345
2024-08-07Don't use LLVM to compute -Ctarget-featureCaleb Zulawski-3/+2
2024-08-07Don't use LLVM's target featuresCaleb Zulawski-2/+6
2024-07-31Rollup merge of #127830 - tgross35:archive-failure-message, r=BoxyUwUMatthias Krüger-1/+3
When an archive fails to build, print the path Currently the output on failure is as follows: Compiling block-buffer v0.10.4 Compiling crypto-common v0.1.6 Compiling digest v0.10.7 Compiling sha2 v0.10.8 Compiling xz2 v0.1.7 error: failed to build archive: No such file or directory error: could not compile `bootstrap` (lib) due to 1 previous error Change this to print which file is being constructed, to give some hint about what is going on. error: failed to build archive at `path/to/output`: No such file or directory
2024-07-30Move mingw dlltool invocation to cg_ssabjorn3-126/+12
2024-07-30Move computation of decorated names out of the create_dll_import_lib methodbjorn3-18/+3
2024-07-30Move is_mingw_gnu_toolchain and i686_decorated_name to cg_ssabjorn3-1/+1
2024-07-30Move temp file name generation out of the create_dll_import_lib methodbjorn3-10/+4
2024-07-29Reformat `use` declarations.Nicholas Nethercote-65/+57
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-16Rollup merge of #124033 - bjorn3:ar_archive_writer_0_3_0, r=davidtwcoTrevor Gross-42/+67
Sync ar_archive_writer to LLVM 18.1.3 From LLVM 15.0.0-rc3. This adds support for COFF archives containing Arm64EC object files and has various fixes for AIX big archive files.
2024-07-16When an archive fails to build, print the pathTrevor Gross-1/+3
Currently the output on failure is as follows: Compiling block-buffer v0.10.4 Compiling crypto-common v0.1.6 Compiling digest v0.10.7 Compiling sha2 v0.10.8 Compiling xz2 v0.1.7 error: failed to build archive: No such file or directory error: could not compile `bootstrap` (lib) due to 1 previous error Print which file is being constructed to give some hint about what is going on.
2024-07-16Fix unsafe_op_in_unsafe_fn in compilerMichael Goulet-115/+137