Commit graph

428 commits

Author SHA1 Message Date
Yuki Okushi
fa38fad5a2
Rollup merge of #86025 - bjorn3:no_rpath_cfg_prefix, r=jackh726
Remove the install prefix from the rpath set when using -Crpath

It was broken anyway for rustup installs and nobody seems to have noticed.

Fixes https://github.com/rust-lang/rust/issues/82392
2021-06-07 15:21:04 +09:00
Yuki Okushi
4144019847
Rollup merge of #86016 - luqmana:infer-linker-flavor, r=petrochenkov
Unify duplicate linker_and_flavor methods in rustc_codegen_{cranelift,ssa}.

The two methods were exactly the same so this removes the cranelift copy. This will help make sure both they don't get out of sync.
2021-06-07 15:21:03 +09:00
Tomasz Miąsko
4237a05233 Use preorder traversal when checking for SSA locals
When rebuilding the standard library, this change reduces the number of
locals that require an alloca from 62452 to 62348.
2021-06-07 05:33:49 +02:00
bors
cc9610bf5a Auto merge of #85810 - bjorn3:further_driver_cleanup, r=varkor
Driver improvements

This PR contains a couple of cleanups for the driver and a few small improvements for the custom codegen backend interface. It also implements `--version` and `-Cpasses=list` support for custom codegen backends.
2021-06-07 02:30:24 +00:00
Guillaume Gomez
a3c76f6d98
Rollup merge of #85965 - tmiasko:a, r=nagisa
Remove dead code from `LocalAnalyzer`
2021-06-07 01:06:51 +02:00
Vadim Petrochenkov
3eab280567 linker: Re-apply Solaris fixes for -z ignore 2021-06-06 17:48:18 +03:00
Vadim Petrochenkov
5275bf1c1d linker: Restore the old order of linking native libraries 2021-06-06 17:30:32 +03:00
Vadim Petrochenkov
b7994f9e7e linker: Reorder linker arguments
- Combine all native library arguments together, to simplify potential support for library deduplication and similar things
- Split arguments into order-independent and order-dependent, to define more precisely what (pre,post,late)-link-args mean
2021-06-06 17:30:30 +03:00
Vadim Petrochenkov
dca3acb6c2 linker: Inline fn link_local_crate_native_libs_and_dependent_crate_libs 2021-06-06 17:29:13 +03:00
Yuki Okushi
679a1d1ac1
Rollup merge of #85920 - luqmana:wasm-linker-tweaks, r=petrochenkov
Tweak wasm_base target spec to indicate linker is not GNU and update linker inferring logic for wasm-ld.

Reported via [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/wasi.20linker.20unknown.20argument.3A.20--as-needed): we try passing `--as-needed` to the linker if it's GNU ld which `wasm-ld` is not. Usually this isn't an issue for wasm as we would use the WasmLd linker driver but because the linker in question (`wasm32-unknown-wasi-wasm-ld`) ended with `-ld` our linker inferring [logic](f64503eb55/compiler/rustc_codegen_ssa/src/back/link.rs (L957-L1040)) used the `GccLinker` implementations. (UPD: The linker inferring logic actually didn't apply in this case because the linker is actually invoked through gcc in the reported issue. But it's still worth updating the logic I think.)

This change then has 2 parts:
1. Update wasm_base target spec to indicate `linker_is_gnu: false` plus a few additions of `target.is_like_wasm` to handle flags `wasm-ld` does in fact support.
2. Improve the linker detection logic to properly determine the correct flavor of wasm linker we're using when we can.

We need to add the new `target.is_like_wasm` branches to handle the case where the "linker" used could be something like clang which would then under the hood call wasm-ld.
2021-06-06 19:11:18 +09:00
Yuki Okushi
d69cd46761
Rollup merge of #85772 - luqmana:ignored-metadata, r=petrochenkov
Preserve metadata w/ Solaris-like linkers.

#84468 moved the `-zignore` linker flag from the `gc_sections` method to `add_as_needed` which is more accurate but Solaris-style linkers will also end up removing an unreferenced ELF sections [1]. This had the unfortunate side effect of causing the `.rustc` section (which has the metada) to be removed which could cause issues when trying to link against the resulting crates or use proc macros.

Since the `-zignore` is positional, we fix this by moving the metadata objects to before the flag.

[1] Specifically a section is considered unreferenced if:
* The section is allocatable
* No other sections bind to (relocate) to this section
* The section provides no global symbols

https://docs.oracle.com/cd/E19683-01/817-3677/6mj8mbtbs/index.html#chapter4-19
2021-06-06 19:11:17 +09:00
Luqman Aden
a26f00357f Unify duplicate linker_and_flavor methods in rustc_codegen_{cranelift,ssa}. 2021-06-05 21:59:41 -07:00
bors
9a576175cc Auto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkov
Partial support for raw-dylib linkage

First cut of functionality for issue #58713: add support for `#[link(kind = "raw-dylib")]` on `extern` blocks in lib crates compiled to .rlib files.  Does not yet support `#[link_name]` attributes on functions, or the `#[link_ordinal]` attribute, or `#[link(kind = "raw-dylib")]` on `extern` blocks in bin crates; I intend to publish subsequent PRs to fill those gaps.  It's also not yet clear whether this works for functions in `extern "stdcall"` blocks; I also intend to investigate that shortly and make any necessary changes as a follow-on PR.

This implementation calls out to an LLVM function to construct the actual `.idata` sections as temporary `.lib` files on disk and then links those into the generated .rlib.
2021-06-06 03:59:17 +00:00
bors
f434217aab Auto merge of #79608 - alessandrod:bpf, r=nagisa
BPF target support

This adds `bpfel-unknown-none` and `bpfeb-unknown-none`, two new no_std targets that generate little and big endian BPF. The approach taken is very similar to the cuda target, where `TargetOptions::obj_is_bitcode` is enabled and code generation is done by the linker.

I added the targets to `dist-various-2`. There are [some tests](https://github.com/alessandrod/bpf-linker/tree/main/tests/assembly) in bpf-linker and I'm planning to add more. Those are currently not ran as part of rust CI.
2021-06-06 01:02:32 +00:00
bjorn3
6b45d59caa Remove get_install_prefix_lib_path completely
It was broken anyway for rustup installs and nobody seems to have noticed.
2021-06-05 16:42:03 +02:00
bjorn3
a3205a6698 Use sysroot instead of CFG_PREFIX for the rpath
CFG_PREFIX is incorrect for rustup installed rustc versions. It also
causes unnecessary recompilation when changing the install prefix.
2021-06-05 16:42:03 +02:00
bors
9104c898eb Auto merge of #85869 - tmiasko:box-free, r=nagisa
Remove special handling of `box_free` from `LocalAnalyzer`

The special casing of `box_free` predates the use of dominators in
analyzer. It is no longer necessary now that analyzer verifies that
the first assignment dominates all uses.
2021-06-05 14:08:38 +00:00
Richard Cobbe
6aa45b71b1 Add first cut of functionality for #58713: support for #[link(kind = "raw-dylib")].
This does not yet support #[link_name] attributes on functions, the #[link_ordinal]
attribute, #[link(kind = "raw-dylib")] on extern blocks in bin crates, or
stdcall functions on 32-bit x86.
2021-06-04 18:01:35 -07:00
bors
c79419af07 Auto merge of #84449 - alexcrichton:metadata-in-object, r=nagisa
rustc: Store metadata-in-rlibs in object files

This commit updates how rustc compiler metadata is stored in rlibs.
Previously metadata was stored as a raw file that has the same format as
`--emit metadata`. After this commit, however, the metadata is encoded
into a small object file which has one section which is the contents of
the metadata.

The motivation for this commit is to fix a common case where #83730
arises. The problem is that when rustc crates a `dylib` crate type it
needs to include entire rlib files into the dylib, so it passes
`--whole-archive` (or the equivalent) to the linker. The problem with
this, though, is that the linker will attempt to read all files in the
archive. If the metadata file were left as-is (today) then the linker
would generate an error saying it can't read the file. The previous
solution was to alter the rlib just before linking, creating a new
archive in a temporary directory which has the metadata file removed.

This problem from before this commit is now removed if the metadata file
is stored in an object file that the linker can read. The only caveat we
have to take care of is to ensure that the linker never actually
includes the contents of the object file into the final output. We apply
similar tricks as the `.llvmbc` bytecode sections to do this.

This involved changing the metadata loading code a bit, namely updating
some of the LLVM C APIs used to use non-deprecated ones and fiddling
with the lifetimes a bit to get everything to work out. Otherwise though
this isn't intended to be a functional change really, only that metadata
is stored differently in archives now.

This should end up fixing #83730 because by default dylibs will no
longer have their rlib dependencies "altered" meaning that
split-debuginfo will continue to have valid paths pointing at the
original rlibs. (note that we still "alter" rlibs if LTO is enabled to
remove Rust object files and we also "alter" for the #[link(cfg)]
feature, but that's rarely used).

Closes #83730
2021-06-04 19:29:50 +00:00
Alex Crichton
0e0338744d rustc: Store metadata-in-rlibs in object files
This commit updates how rustc compiler metadata is stored in rlibs.
Previously metadata was stored as a raw file that has the same format as
`--emit metadata`. After this commit, however, the metadata is encoded
into a small object file which has one section which is the contents of
the metadata.

The motivation for this commit is to fix a common case where #83730
arises. The problem is that when rustc crates a `dylib` crate type it
needs to include entire rlib files into the dylib, so it passes
`--whole-archive` (or the equivalent) to the linker. The problem with
this, though, is that the linker will attempt to read all files in the
archive. If the metadata file were left as-is (today) then the linker
would generate an error saying it can't read the file. The previous
solution was to alter the rlib just before linking, creating a new
archive in a temporary directory which has the metadata file removed.

This problem from before this commit is now removed if the metadata file
is stored in an object file that the linker can read. The only caveat we
have to take care of is to ensure that the linker never actually
includes the contents of the object file into the final output. We apply
similar tricks as the `.llvmbc` bytecode sections to do this.

This involved changing the metadata loading code a bit, namely updating
some of the LLVM C APIs used to use non-deprecated ones and fiddling
with the lifetimes a bit to get everything to work out. Otherwise though
this isn't intended to be a functional change really, only that metadata
is stored differently in archives now.

This should end up fixing #83730 because by default dylibs will no
longer have their rlib dependencies "altered" meaning that
split-debuginfo will continue to have valid paths pointing at the
original rlibs. (note that we still "alter" rlibs if LTO is enabled to
remove Rust object files and we also "alter" for the #[link(cfg)]
feature, but that's rarely used).

Closes #83730
2021-06-04 10:05:20 -07:00
bjorn3
e30490d5b2 Move crate_name field from OngoingCodegen to CrateInfo 2021-06-04 13:20:05 +02:00
bjorn3
96247017fa Move windows_subsystem field from CodegenResults to CrateInfo 2021-06-04 13:20:04 +02:00
bjorn3
f04a2d308e Provide default MetadataLoader 2021-06-04 13:20:04 +02:00
bjorn3
f299256854 Remove unnecessary wasm_import_module_map provide
For extern providers, both provide and provide_extern are called.
wasm_import_module_map is already provided in provide, so it doesn't
need to be provided in provide_extern.
2021-06-04 13:20:04 +02:00
bjorn3
092bc2b744 Provide a default provide* implementation for CodegenBackend
Both cg_llvm and cg_clif don't override it. cg_spirv does override it,
so it needs to be preserved.
2021-06-04 13:20:04 +02:00
bors
289ada5ed4 Auto merge of #85385 - richkadel:simpler-simplify-with-coverage, r=wesleywiser
Reland - Report coverage `0` of dead blocks

Fixes: #84018

With `-Z instrument-coverage`, coverage reporting of dead blocks
(for example, blocks dropped because a conditional branch is dropped,
based on const evaluation) is now supported.

Note, this PR relands an earlier, reverted PR that failed when compiling
generators. The prior issues with generators has been resolved and a new
test was added to prevent future regressions.

Check out the resulting changes to test coverage of dead blocks in the
test coverage reports in this PR.

r? `@tmandry`
fyi: `@wesleywiser`
2021-06-04 10:18:54 +00:00
Yuki Okushi
36f1ed6de2
Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514
Remove unused feature gates

The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`)

The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though.

The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-04 13:42:54 +09:00
Tomasz Miąsko
624c693508 Remove check for projections in a branch without any
The else branch is taken when projection slice is empty so everything
except for the call to the `visit_local` is a dead code.
2021-06-03 16:29:38 +02:00
Tomasz Miąsko
59b6583287 Remove unused support for VarDebugInfo
This code has been dead since changes in 68961.
2021-06-03 16:29:21 +02:00
Wesley Wiser
3127419e2b Respond to review feedback 2021-06-02 10:23:12 -04:00
Wesley Wiser
ef053fd6f0 Change the type name from _enum<..> to enum$<..>
This makes the type name inline with the proposed standard in #85269.
2021-06-02 10:23:12 -04:00
Wesley Wiser
141546c355 Generate better debuginfo for niche-layout enums
Previously, we would generate a single struct with the layout of the
dataful variant plus an extra field whose name contained the value of
the niche (this would only really work for things like `Option<&_>`
where we can determine that the `None` case maps to `0` but for enums
that have multiple tag only variants, this doesn't work).

Now, we generate a union of two structs, one which is the layout of the
dataful variant and one which just has a way of reading the
discriminant. We also generate an enum which maps the discriminant value
to the tag only variants.

We also encode information about the range of values which correspond to
the dataful variant in the type name and then use natvis to determine
which union field we should display to the user.

As a result of this change, all niche-layout enums render correctly in
WinDbg and Visual Studio!
2021-06-02 10:23:10 -04:00
Wesley Wiser
f353cbf1a1 Generate better debuginfo for directly tagged enums 2021-06-02 10:23:09 -04:00
Luqman Aden
f667aca127 Tweak wasm_base target spec to indicate linker is not GNU and update linker inferring logic for wasm-ld. 2021-06-01 17:13:10 -07:00
Rich Kadel
f4f76e60b3 Reland - Report coverage 0 of dead blocks
Fixes: #84018

With `-Z instrument-coverage`, coverage reporting of dead blocks
(for example, blocks dropped because a conditional branch is dropped,
based on const evaluation) is now supported.

Note, this PR relands an earlier, reverted PR that failed when compiling
generators. The prior issues with generators has been resolved and a new
test was added to prevent future regressions.

Check out the resulting changes to test coverage of dead blocks in the
test coverage reports in this PR.
2021-06-01 13:28:59 -07:00
Camille Gillot
0f0f3138cb
Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
bjorn3
312f964478 Remove unused feature gates 2021-05-31 13:55:43 +02:00
Tomasz Miąsko
76695c41da Remove special handling of box_free from LocalAnalyzer
The special casing of `box_free` predates the use of dominators in
analyzer. It is no longer necessary now that analyzer verifies that
the first assignment dominates all uses.
2021-05-31 00:00:00 +00:00
Camille GILLOT
ee94fbb607 Make allocator_kind a query. 2021-05-30 19:58:01 +02:00
Luqman Aden
cffef3385d Move metadata objects to before as-needed/zignore flags to make sure they are kept. 2021-05-27 22:13:39 -07:00
Dylan DPC
0c53acc6f8
Rollup merge of #85649 - ChrisDenton:update-cc, r=matthewjasper
Update cc

Recent commits have improved `cc`'s finding of MSVC tools on Windows. In particular it should help to address these issues: #83043 and #43468
2021-05-27 03:02:09 +02:00
Chris Denton
e238ee31d4
Update cc
Recent commits to cc have helped to address #83043 and #43468
2021-05-24 23:34:12 +01:00
Pietro Albini
9e22b844dd remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
Alessandro Decina
b2a6967114 Add support for BPF inline assembly 2021-05-23 18:03:27 +10:00
Alessandro Decina
12ac719b99 Pass target features to bpf-linker 2021-05-23 18:03:27 +10:00
Alessandro Decina
25b3c88771 Fix formatting 2021-05-23 18:03:27 +10:00
Alessandro Decina
12e70929d6 Add BPF target
This change adds the bpfel-unknown-none and bpfeb-unknown-none targets
which can be used to generate little endian and big endian BPF
2021-05-23 18:03:27 +10:00
12101111
004614c4b3
native lib: defer the duplicate check after relevant_lib check. 2021-05-22 00:09:07 +08:00
bors
8a57820bca Auto merge of #84665 - adamgemmell:aarch64-features, r=Amanieu
Update list of allowed aarch64 features

I recently added these features to std_detect for aarch64 linux, pending [review](https://github.com/rust-lang/stdarch/pull/1146).

I have commented any features not supported by LLVM 9, the current minimum version for Rust. Some (PAuth at least) were renamed between 9 & 12 and I've left them disabled. TME, however, is not in LLVM 9 but I've left it enabled.

See https://github.com/rust-lang/stdarch/issues/993
2021-05-20 13:07:35 +00:00
Adam Gemmell
904467a926 Ensure all crypto components (AES, PMULL, SHA1/2) are available on arm/aarch64 2021-05-19 16:13:23 +01:00
Adam Gemmell
c71e58d432 Rename fptoint to frintts 2021-05-19 16:12:30 +01:00
Adam Gemmell
523b4d1499 Remove LSE2 2021-05-19 16:11:11 +01:00
Jack Huey
ec0e0d1e7a
Rollup merge of #85274 - luqmana:linker-is-gnu-gc-sections, r=petrochenkov
Only pass --[no-]gc-sections if linker is GNU ld.

Fixes a regression from #84468 where linking now fails with solaris linkers. LinkerFlavor::Gcc does not always mean GNU ld specifically. And in the case of at least the solaris ld in illumos, that flag is unrecognized and will cause the linking step to fail.

Even though removing the `is_like_solaris` branch from `gc_sections` in #84468 made sense as `-z ignore/record` are more analogous to the `--[no-]-as-needed` flags, it inadvertently caused solaris linkers to be passed the `--gc-sections` flag. So let's just change it to be more explicit about when we pass those flags.
2021-05-18 22:36:04 -04:00
Luqman Aden
ac5fd90d82 Don't pass -pie to linker on windows targets. 2021-05-18 03:57:53 -07:00
Luqman Aden
e0d5872503 Undo unnecessary changes. 2021-05-18 02:44:07 -07:00
Luqman Aden
a862b1f6cc Adjust linker_is_gnu branches for cases that don't work on windows. 2021-05-17 16:14:13 -07:00
bors
3396a383bb Auto merge of #85178 - cjgillot:local-crate, r=oli-obk
Remove CrateNum parameter for queries that only work on local crate

The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea.

Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-17 01:42:03 +00:00
Eduard-Mihai Burtescu
0fcaf11455 rustc_codegen_ssa: append blocks to functions w/o creating a builder. 2021-05-17 00:04:09 +03:00
Eduard-Mihai Burtescu
402e9efc56 rustc_codegen_ssa: only create backend BasicBlocks as-needed. 2021-05-17 00:04:09 +03:00
bors
7dc9ff5c62 Auto merge of #85290 - Amanieu:asm_const_int, r=nagisa
Remove support for floating-point constants in asm!

Floating-point constants aren't very useful anyways and this simplifies
the code since the type check can now be done in typeck.

cc `@rust-lang/wg-inline-asm`

r? `@nagisa`
2021-05-16 17:52:52 +00:00
bors
747a5d2a5d Auto merge of #85316 - eddyb:cg-ssa-on-demand-cleanuppad, r=nagisa
rustc_codegen_ssa: generate MSVC cleanup pads on demand, like GNU landing pads.

This unblocks #84993 in terms of codegen tests, as it brings the MSVC-style (`cleanup_pad`) EH (LLVM) block order in line with the GNU-style (`landing_pad`) EH (LLVM) block order, by having both of them be on-demand (instead of MSVC-style being eager and GNU-style lazy/on-demand).

It also unifies the two implementations a bit, similar to #84699, but in the opposite direction (as that attempt made both kinds of EH pads eagerly built).

~~Opening as draft because I haven't done enough Windows testing just yet, of both this PR, and of #84993 rebased on it.~~ (**EDIT**: seems to be working as expected)

r? `@nagisa`
2021-05-16 12:30:07 +00:00
Guillaume Gomez
e611e64e3a
Rollup merge of #85215 - richkadel:ice-fixes-minus-dead-blocks, r=tmandry
coverage bug fixes and some refactoring

This replaces the relevant commits (2 and 3) from PR #85082, and also corrects an error querying for coverageinfo.

1. `coverageinfo` query needs to use the same MIR as codegen

I ran into an error trying to fix dead block coverage and realized the
`coverageinfo` query is getting a different MIR compared to the
codegenned MIR, which can sometimes be a problem during mapgen.

I changed that query to use the `InstandeDef` (which includes the
generic parameter substitutions, prosibly specific to const params)
instead of the `DefId` (without unknown/default const substitutions).

2. Simplified body_span and filtered span code

  Some code cleanup extracted from future (but unfinished) commit to fix
  coverage in attr macro functions.

3. Spanview needs the relevant body_span used for coverage

The coverage body_span doesn't always match the function body_span.

r? ```@tmandry```
2021-05-15 13:29:49 +02:00
Eduard-Mihai Burtescu
cb23a794a6 rustc_codegen_ssa: generate MSVC cleanup pads on demand, like GNU landing pads. 2021-05-15 09:17:46 +03:00
Amanieu d'Antras
f1b11939e2 Remove support for floating-point constants in asm!
Floating-point constants aren't very useful anyways and this simplifies
the code since the type check can now be done in typeck.
2021-05-14 14:58:21 +01:00
bors
75da570d78 Auto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisa
Use the object crate for metadata reading

This allows sharing the metadata reader between cg_llvm, cg_clif and other codegen backends.

This is not currently useful for rlib reading with cg_spirv ([rust-gpu](https://github.com/EmbarkStudios/rust-gpu/)) as it uses tar rather than ar as .rlib format, but it is useful for dylib reading required for loading proc macros. (cc `@eddyb)`

The object crate is already trusted as dependency of libstd through backtrace. As far as I know it supports reading all object file formats used by targets for which we support rust dylibs with crate metadata, but I am not certain. If this happens to not be the case, I could keep using LLVM for reading dylib metadata.

Marked as WIP for a perf run and as it is based on #83637.
2021-05-14 12:58:58 +00:00
bors
91f2e2d218 Auto merge of #85190 - mati865:update-cc, r=Mark-Simulacrum
Update cc crate

To pull in this fix: 801a87bf2f
2021-05-14 04:12:40 +00:00
Luqman Aden
3fe1d7f789 Only pass --[no-]gc-sections if linker is GNU ld.
LinkerFlavor::Gcc does not always mean GNU ld specifically. And in the
case of at least the solaris ld in illumos, that flag is unrecognized
and will cause the linking step to fail.
2021-05-13 16:55:33 -07:00
Amanieu d'Antras
5918ee4317 Add support for const operands and options to global_asm!
On x86, the default syntax is also switched to Intel to match asm!
2021-05-13 22:31:57 +01:00
Rich Kadel
aed8ef5a4d coverageinfo query needs to use the same MIR as codegen
I ran into an error trying to fix dead block coverage and realized the
`coverageinfo` query is getting a different MIR compared to the
codegenned MIR, which can sometimes be a problem during mapgen.

I changed that query to use the `InstandeDef` (which includes the
generic parameter substitutions, prosibly specific to const params)
instead of the `DefId` (without unknown/default const substitutions).
2021-05-12 20:27:07 -07:00
Ralf Jung
44a8e8d745 entirely remove rustc_args_required_const attribute 2021-05-12 16:15:27 +02:00
Camille GILLOT
0bde3b1f80 Use () for codegen queries. 2021-05-12 13:58:46 +02:00
Camille GILLOT
437a46ddfa Use () for lang items. 2021-05-12 13:58:45 +02:00
Camille GILLOT
b7bf467fa3 Use () for proc_macro_decls_static. 2021-05-12 13:58:43 +02:00
Camille GILLOT
e9e1900af7 Use () for plugin_registrar_fn. 2021-05-12 13:58:43 +02:00
Camille GILLOT
829a9d33a9 Use () for entry_fn. 2021-05-12 13:58:42 +02:00
Camille GILLOT
3a729915da Use () in reachable_set. 2021-05-12 13:58:42 +02:00
Camille GILLOT
85a14d70bb Use () in dependency_formats. 2021-05-12 13:58:41 +02:00
bors
e1ff91f439 Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths

This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped.

`RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path.

`RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure.

When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host".

`rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`.

cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-12 11:05:56 +00:00
bors
ac923d94f8 Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot
rustc_driver cleanup

Best reviewed one commit at a time.
2021-05-12 08:38:03 +00:00
Mateusz Mikuła
b04fd78d66 update cc crate
To pull in this fix: 801a87bf2f
2021-05-12 00:55:03 +02:00
Simonas Kazlauskas
b7c5599d22 Adjust target search algorithm for rustlib path
With this the concerns expressed in #83800 should be addressed.
2021-05-10 19:15:19 +03:00
bjorn3
487427fbe6 Better error messages 2021-05-10 09:49:42 +02:00
bors
d29289c509 Auto merge of #84507 - crlf0710:codegen_nonlocal_main_wrapper, r=nagisa
Add primary marker on codegen unit and generate main wrapper on primary codegen.

This is the codegen part of changes extracted from #84062.

This add a marker called `primary` on each codegen units, where exactly one codegen unit will be `primary = true` at a time. This specific codegen unit will take charge of generating `main` wrapper when `main` is imported from a foreign crate after the implementation of RFC 1260.

cc #28937

I'm not sure who should i ask for review for codegen changes, so feel free to reassign.
r? `@nagisa`
2021-05-10 00:42:31 +00:00
Charles Lew
89a67051a7 Add primary marker on codegen unit to take charge of main_wrapper for non-local cases. 2021-05-09 10:52:03 +08:00
Nikita Popov
c2b15a6b64 Support -C passes in NewPM
And report an error if parsing the additional pass pipeline fails.
Threading through the error accounts for most of the changes here.
2021-05-08 10:58:08 +02:00
Nikita Popov
db140de8f2 Explicitly register GCOV profiling pass as well 2021-05-08 10:58:08 +02:00
Nikita Popov
5ecbe7fcf8 Explicitly register instrprof pass
Don't use "passes" for this purpose, explicitly insert it into
the correct place in the pipeline instead.
2021-05-08 10:58:08 +02:00
Nikita Popov
0318883cd6 Make -Z new-llvm-pass-manager an Option<bool>
To allow it to have an LLVM version dependent default.
2021-05-08 10:58:08 +02:00
Dylan DPC
b5092627c7
Rollup merge of #85044 - ChrisDenton:file-exists, r=jackh726
Use `path.exists()` instead of `fs::metadata(path).is_ok()`

It's more explicit and potentially allows platforms to optimize the existence check.
2021-05-08 01:06:26 +02:00
bjorn3
802fe1756b Disable wasm feature of object in cg_ssa
The version 1 resolver unifies enabled features across the
whole workspace. This includes libstd which isn't allowed
to depend on wasmparser.
2021-05-07 18:57:25 +02:00
bjorn3
267d55d44a Use the object crate for metadata reading 2021-05-07 18:48:58 +02:00
Chris Denton
d9a58f4c87
Use path.exists() instead of fs::metadata(path).is_ok()
It's more explicit and allows platforms to optimize the existence check.
2021-05-07 17:32:40 +01:00
Dylan DPC
6e4c842305
Rollup merge of #84866 - petrochenkov:wholesome, r=Mark-Simulacrum
linker: Avoid library duplication with `/WHOLEARCHIVE`

Looks like in #72785 I misinterpreted how the `link.exe`'s `/WHOLEARCHIVE` flag works.

It's not necessary to write `mylib /WHOLEARCHIVE:mylib` to mark `mylib` as whole archive, `/WHOLEARCHIVE:mylib` alone is enough.

https://docs.microsoft.com/en-us/cpp/build/reference/wholearchive-include-all-library-object-files?view=msvc-160
2021-05-07 16:19:20 +02:00
Joshua M. Clulow
31c2ad0d4c illumos should put libc last in library search order
Under some conditions, the toolchain will produce a sequence of linker
arguments that result in a NEEDED list that puts libc before libgcc_s;
e.g.,

    [0]  NEEDED            0x2046ba            libc.so.1
    [1]  NEEDED            0x204723            libm.so.2
    [2]  NEEDED            0x204736            libsocket.so.1
    [3]  NEEDED            0x20478b            libumem.so.1
    [4]  NEEDED            0x204763            libgcc_s.so.1

Both libc and libgcc_s provide an unwinder implementation, but libgcc_s
provides some extra symbols upon which Rust directly depends.  If libc
is first in the NEEDED list we will find some of those symbols in libc
but others in libgcc_s, resulting in undefined behaviour as the two
implementations do not use compatible interior data structures.

This solution is not perfect, but is the simplest way to produce correct
binaries on illumos for now.
2021-05-06 17:08:10 -07:00
Vadim Petrochenkov
fb9feb35ed linker: Avoid library duplication with /WHOLEARCHIVE 2021-05-06 21:22:25 +03:00
Dylan DPC
5dcdeb81e1
Rollup merge of #83507 - luqmana:native-link-modifiers, r=petrochenkov
Implement RFC 2951: Native link modifiers

A first attempt at implementing https://github.com/rust-lang/rfcs/pull/2951 / https://github.com/rust-lang/compiler-team/issues/356.

Tracking Issue: https://github.com/rust-lang/rust/issues/81490

Introduces feature flags for the general syntax (`native_link_modifiers`) and each modifier (`native_link_modifiers_{as_needed,bundle,verbatim,whole_archive}`).

r? `@petrochenkov`
2021-05-06 13:30:51 +02:00
bors
1d99508b52 Auto merge of #84468 - iladin:iladin/fix-84467, r=petrochenkov
Fix#84467 linker_args with --target=sparcv9-sun-solaris

Trying to cross-compile for sparcv9-sun-solaris
getting a error message for -zignore

Introduced when -z -ignore was seperated here
22d0ab0

No formatting done

Reproduce

``` bash
rustup target add sparcv9-sun-solaris
cargo new --bin hello && cd hello && cargo run --target=sparcv9-sun-solaris
```

config.toml

[target.sparcv9-sun-solaris]
linker = "gcc"
2021-05-06 07:02:06 +00:00
Luqman Aden
db555e1284 Implement RFC 2951: Native link modifiers
This commit implements both the native linking modifiers infrastructure
as well as an initial attempt at the individual modifiers from the RFC.
It also introduces a feature flag for the general syntax along with
individual feature flags for each modifier.
2021-05-05 16:04:25 -07:00
Andy Wang
5417b45c26
Use local and remapped paths where appropriate 2021-05-05 15:31:28 +01:00
bjorn3
c47eeac612 Move wasm_import_module_map provider to cg_ssa 2021-05-02 18:00:20 +02:00