-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustc needs sensible options for the emission of LLVM IR/LLVM bitcode/ASM #7791
Comments
Allowing multiple |
@huonw When I was thrashing the idea out in #rust last night I considered both those forms, but decided |
I would support having |
@sstewartgallus assuming a default of How this fits in with |
Concrete proposal:
Merges |
I do like the idea of consolidating what is now like 8 flags into one, although there's one complication that I can think of. Currently the lib/bin distinction affects codegen in terms of visibility of functions, so with I suppose we could default to "output the library IR", but if you're debugging IR for reachability optimizations you may not want that. I think I'd be ok with this as the default. I do like the idea of one Nominating, I'm mostly a fan of this proposal and if we're doing this for 1.0 we need to remove the existing flags sooner rather than later. |
Hm. Let's take a hint from ad-hoc URL protocol composition! |
What about: |
This just gets more and more appealing!
That's the full and complete list I can think of, although |
|
Can we keep |
we should also consider compatibility with clang's flags |
accepted for first major release, P-back-compat-libs |
I don't really like maintaining cli flag compatibility with other compilers. It seems incredibly unimportant, since we're not aiming to be a drop-in replacement for any compiler (unlike clang/icc which aim to emulate gcc) |
Also should consider #612 and potential future isomorphisms between command line flags and crate attributes. |
I've attempted a scheme in #12020 with |
This commit removes the -c, --emit-llvm, -s, --rlib, --dylib, --staticlib, --lib, and --bin flags from rustc, adding the following flags: * --emit=[asm,ir,bc,obj,link] * --crate-type=[dylib,rlib,staticlib,bin,lib] The -o option has also been redefined to be used for *all* flavors of outputs. This means that we no longer ignore it for libraries. The --out-dir remains the same as before. The new logic for files that rustc emits is as follows: 1. Output types are dictated by the --emit flag. The default value is --emit=link, and this option can be passed multiple times and have all options stacked on one another. 2. Crate types are dictated by the --crate-type flag and the #[crate_type] attribute. The flags can be passed many times and stack with the crate attribute. 3. If the -o flag is specified, and only one output type is specified, the output will be emitted at this location. If more than one output type is specified, then the filename of -o is ignored, and all output goes in the directory that -o specifies. The -o option always ignores the --out-dir option. 4. If the --out-dir flag is specified, all output goes in this directory. 5. If -o and --out-dir are both not present, all output goes in the directory of the crate file. 6. When multiple output types are specified, the filestem of all output is the same as the name of the CrateId (derived from a crate attribute or from the filestem of the crate file). Closes #7791 Closes #11056 Closes #11667
…type, r=giraffate Allow giving reasons for `disallowed_types` Similar to rust-lang#7609 but for the `disallowed_type` lint. The permitted form of configuration is the same as for `disallowed_methods`. changelog: Allow giving reasons for [`disallowed_type`]
At present,
rustc foo.rs
emits a binary;rustc --emit-llvm foo.rs
emits LLVM bitcode;rustc -S foo.rs
emits the final Assembler code;rustc --emit-llvm -S foo.rs
emits LLVM IR.This is madness!
Here is my desired behaviour:
rustc --emit-binary foo.rs
emits a binary;rustc --emit-llvm-bc foo.rs
emits LLVM bitcode;rustc --emit-asm foo.rs
emits the final Assembler code;rustc --emit-llvm-ir foo.rs
emits LLVM IR.More than one of these options may be specified, in which case multiple things would be built; if no
--emit-*
option is specified, it will of course default to--emit-binary
.A brief look at the code suggests that at present it is only designed to produce one of these. An alternative, if staying within this constraint, would be
--emit=(binary|llvm-(bc|ir)|asm)
; however, I feel allowing multiple outputs would be nicer, though I guess just-o
wouldn't cut it.The text was updated successfully, but these errors were encountered: