Commit Graph

481 Commits

Author SHA1 Message Date
Dylan DPC
b15423e72e
Rollup merge of #70384 - nnethercote:refactor-object-file-handling, r=alexcrichton
Refactor object file handling

Some preliminary clean-ups that grease the path to #66961.

r? @alexcrichton
2020-03-26 21:44:02 +01:00
Dylan DPC
818da9eb4d
Rollup merge of #69700 - anyska:layout-details-rename, r=oli-obk
Rename LayoutDetails to just Layout.
2020-03-25 23:52:57 +01:00
Ana-Maria Mihalache
0f7840b89b Rename LayoutDetails to just Layout. 2020-03-25 15:06:48 +00:00
Ralf Jung
7400955e94 add usize methods for Size getters 2020-03-25 15:53:53 +01:00
Ralf Jung
0bc108a13b make Size::from* methods generic in the integer type they accept 2020-03-25 15:53:52 +01:00
Ralf Jung
d7e2650db2 miri: avoid a bunch of casts by offering usized-based field indexing 2020-03-25 15:53:52 +01:00
Nicholas Nethercote
e1d1db790f Remove TargetOptions::embed_bitcode.
It's unused by any existing targets, and soon we'll be embedding full
bitcode by default anyway.
2020-03-25 14:09:27 +11:00
Ana-Maria Mihalache
fcb4e771a6 Split long derive lists into two derive attributes. 2020-03-23 14:48:59 +00:00
Matthias Krüger
e45fdcfa9a remove unused unit values (clippy::unused_unit) 2020-03-21 20:45:19 +01:00
Matthias Krüger
54e103b2f9 don't convert results to options just for matching (clippy::if_let_some_result) 2020-03-21 15:24:48 +01:00
Mazdak Farrokhzad
937ca434b1
Rollup merge of #70189 - RalfJung:is_signed, r=eddyb
Abi::is_signed: assert that we are a Scalar

A bit more sanity checking, suggested by @eddyb. This makes this method actually "safer" than `TyS::is_signed`, so I made sure Miri consistently uses the `Abi` version.

Though I am not sure if this would have caught the mistake where the layout of a zero-sized enum was asked for its sign.

r? @eddyb
2020-03-21 05:33:35 +01:00
Ralf Jung
5930da4465 Abi::is_signed: assert that we are a Scalar 2020-03-20 17:05:00 +01:00
Yuki Okushi
3554f2d941
Rollup merge of #69768 - oli-obk:union_field_ice, r=eddyb,RalfJung
Compute the correct layout for variants of uninhabited enums

r? @eddyb
cc @RalfJung

fixes #69191
cc #69763
2020-03-20 17:02:03 +09:00
Dylan MacKenzie
cc4a5770fa Add requisite feature gates for const assert 2020-03-17 11:15:40 -07:00
bors
be055d96c4 Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrum
Optimize catch_unwind to match C++ try/catch

This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown.

https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great.

This PR, on the other hand, generates the following assembly:

```asm
# -Cpanic=unwind:
	push   rbx
	mov    ebx,0x2a
	call   QWORD PTR [rip+0x1c53c]        # <happy>
	mov    eax,ebx
	pop    rbx
	ret
	mov    rdi,rax
	call   QWORD PTR [rip+0x1c537]        # cleanup function call
	call   QWORD PTR [rip+0x1c539]        # <unfortunate>
	mov    ebx,0xd
	mov    eax,ebx
	pop    rbx
	ret

# -Cpanic=abort:
	push   rax
	call   QWORD PTR [rip+0x20a1]        # <happy>
	mov    eax,0x2a
	pop    rcx
	ret
```

Fixes #64224, and resolves #64222.
2020-03-13 22:43:06 +00:00
Mazdak Farrokhzad
39c6405097
Rollup merge of #69747 - spastorino:rename-rustc-guide, r=pietroalbini
Rename rustc guide

This is in preparation for https://github.com/rust-lang/rustc-guide/issues/470
Needs to be merged after we actually rename the guide.

Have used this to rename:

`git grep -l 'rustc_guide' | xargs sed -i 's/rustc_guide/rustc_dev_guide/g'`
`git grep -l 'rustc-guide' | xargs sed -i 's/rustc-guide/rustc-dev-guide/g'`
`git grep -l 'rustc guide' | xargs sed -i 's/rustc guide/rustc dev guide/g'`
2020-03-12 16:32:19 +01:00
bors
e5e8ba4edc Auto merge of #68191 - simlay:add-tvSO-target, r=nagisa
Added tvOS as targets

This is a first attempt of adding support tvOS as described in #48862. It's got a lot of overlap with [src/librustc_target/spec/apple_ios_base.rs](31dd4f4acb/src/librustc_target/spec/apple_ios_base.rs).

I thought about refactoring `apple_ios_base.rs` to include this as well but that would require each of the ios and tvos targets to be of the something like the form `let base = opts(AppleOS::TV, Arch::Arm64)?;` I also did the same thing for watchOS because from what I can tell, all three targets (iOS, tvOS, and watchOS) have the same logic but have different parameters being sent to `xcrun`. Thoughts?

As far as the `data_layout` and other parameters to `Target`, I did as much research as I could but it really seems that processor in the [iPhone 11 is the same as the apple TV](https://en.wikipedia.org/wiki/Apple-designed_processors) so I didn't change any of those parameters.

I did get this to build and tested that it's actually running the the below logic (because the parameter to `xcrun` is `appletvos` not `tvos`).

I didn't manage to get it to actually compile a file with `fn main(){}` because I don't have the stdlib for `aarch64-apple-tvos` compiled it seems. Is there documentation for this?

Similar to the ending of https://github.com/rust-lang/rust/pull/63467, I'm not sure what to do next.
2020-03-12 04:01:02 +00:00
Oliver Scherer
74608c7f20 Rustfmt and adjust capitalization 2020-03-11 14:31:29 +01:00
Oliver Scherer
cdc730457e Compute the correct layout for variants of uninhabited enums and readd a long lost assertion
This reverts part of commit 9712fa4059.
2020-03-11 13:55:20 +01:00
Mazdak Farrokhzad
a7c2eef2ae
Rollup merge of #66059 - RalfJung:panic-on-non-zero, r=eddyb
mem::zeroed/uninit: panic on types that do not permit zero-initialization

r? @eddyb @oli-obk

Cc https://github.com/rust-lang/rust/issues/62825

Also see [this summary comment](https://github.com/rust-lang/rust/pull/66059#issuecomment-586734747)
2020-03-11 10:36:16 +01:00
Santiago Pastorino
b3b32b74bc
rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
Santiago Pastorino
9d4fdba8be
Rename rustc guide to rustc dev guide 2020-03-10 17:08:16 -03:00
Santiago Pastorino
0037f4e37c
Rename rustc-guide to rustc-dev-guide 2020-03-10 17:08:10 -03:00
Mazdak Farrokhzad
c31b7044c1
Rollup merge of #69646 - RalfJung:layout-visitor, r=eddyb
Miri visitor: detect primitive types based on type, not layout (also, more tests)

I also converted the union-based transmutes to use `mem::transmute` for increased readability.

r? @eddyb @oli-obk
2020-03-08 16:53:36 +01:00
Ralf Jung
6548be2ba9 'fieldless enums' is not what I meant -- it's empty/uninhabited enums, really 2020-03-06 22:41:49 +01:00
Matthias Krüger
136ad015b6 fix various typos 2020-03-06 15:19:31 +01:00
Amanieu d'Antras
8e3467c215 Link to libgcc dynamically on windows-gnu when using dylib crates 2020-03-05 17:36:50 +00:00
Amanieu d'Antras
f4f91f0b2f Remove eh_unwind_resume lang item 2020-03-05 17:36:50 +00:00
bors
c839a7b4c2 Auto merge of #69257 - RalfJung:layout-visitor, r=eddyb
Adjust Miri value visitor, and doc-comment layout components

I realized that I still didn't have quite the right intuition for how our `LayoutDetails` work, so I had to adjust the Miri value visitor to the things I understood better now. I also added some doc-comments to `LayoutDetails` as a hopefully canonical place to note such things.

The main visitor change is that we *first* look at all the fields (according to `FieldPlacement`), and *then* check the variants and handle `Multiple` appropriately. I did not quite realize how orthogonal "fields" and "variants" are.
I also moved the check for the scalar ABI to *after* checking all the fields; this leads to better (more type-driven) error messages.

And it looks like we can finally remove that magic hack for `ty::Generator`. :D

r? @oli-obk for the Miri/visitor changes and @eddyb for the layout docs
The Miri PR is at: https://github.com/rust-lang/miri/pull/1178
2020-03-02 09:37:35 +00:00
Yuki Okushi
559e5ab7ad
Rollup merge of #69549 - mati865:mingw, r=kennytm
Improve MinGW detection when cross compiling

Official mingw-w64 builds, MSYS2 and LLVM MinGW provide both `gcc.exe` and `$ARCH-w64-mingw32-gcc.exe` so they should not regress but I included CI changes to verify it though `@bors try` (I don't have permission).

This change will come handy when cross compiling from Linux or Cygwin since they use `gcc` as native compiler and `$ARCH-w64-mingw32-gcc.exe` for MinGW. This means users will no longer have to override the linker.
2020-03-01 19:28:07 +09:00
Ralf Jung
a09c33e362 move pattern to fn argument 2020-02-29 09:41:59 +01:00
Ralf Jung
729f4cd9ae we cannot short-circuit just becuase the Abi seems harmless
also add tests for ScalarPair enums
2020-02-29 09:27:25 +01:00
Ralf Jung
6e66f586a0 fmt 2020-02-29 09:27:25 +01:00
Ralf Jung
b133d6776f make it even more conservative, and note some FIXMEs 2020-02-29 09:27:25 +01:00
Ralf Jung
d78c4aa62e use valid_range_exclusive for correct overflow handling 2020-02-29 09:27:25 +01:00
Ralf Jung
6fd909b2b1 reference tracking issue 2020-02-29 09:27:25 +01:00
Ralf Jung
503026b622 mem::zeroed/uninit: panic on types that do not permit zero-initialization 2020-02-29 09:27:25 +01:00
Mateusz Mikuła
3713ed67fd Improve MinGW detection when cross compiling 2020-02-28 14:15:06 +01:00
Matthias Krüger
7c84ba1124 use char instead of &str for single char patterns 2020-02-27 14:57:22 +01:00
Ralf Jung
dc92ad4d5b adjust LayoutDetails comments 2020-02-26 10:26:18 +01:00
Sebastian Imlay
259977158e fmt 2020-02-20 10:16:32 -08:00
Ralf Jung
ee49e95e78 doc comments for layout components 2020-02-18 09:34:08 +01:00
Jonas Schievink
27cfb2b9c2 Fix typo 2020-02-18 00:00:06 +01:00
Jonas Schievink
c9b87ac4b3 Don't eliminate frame pointers on thumb targets 2020-02-17 21:46:26 +01:00
Sebastian Imlay
6b17330ef4 Merged apple_tvos_base and apple_ios_base into apple_sdk_base. 2020-02-14 16:05:45 -08:00
Sebastian Imlay
a2661695e8 Merge branch 'master' of github.com:rust-lang/rust into add-tvSO-target 2020-02-14 10:57:45 -08:00
Anthony Ramine
15adbf6e08 Properly use the darwin archive format on Apple targets
See https://github.com/servo/servo/issues/25550.
2020-02-12 12:06:14 +01:00
Dylan DPC
ec0cfd1d01
Rollup merge of #66498 - bjorn3:less_feature_flags, r=Dylan-DPC
Remove unused feature gates

I think many of the remaining unstable things can be easily be replaced with stable things. I have kept the `#![feature(nll)]` even though it is only necessary in `libstd`, to make regressions of it harder.
2020-02-11 16:36:54 +01:00
bors
07a34df18b Auto merge of #68452 - msizanoen1:riscv-abi, r=nagisa,eddyb
Implement proper C ABI lowering for RISC-V

This is necessary for full RISC-V psABI compliance when passing argument across C FFI boundary.

cc @lenary
2020-02-08 18:10:48 +00:00
Eduard-Mihai Burtescu
da33935c26 rustc_target: treat enum variants like union members, in call ABIs. 2020-02-08 06:50:59 +02:00