Skip to content
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

Implement used_on_fn_def #95329

Closed
wants to merge 1 commit into from

Conversation

carbotaniuman
Copy link
Contributor

@carbotaniuman carbotaniuman commented Mar 26, 2022

This lets one place the #[used] attribute on function definitions. This is useful when writing
a functions as a library to be linked in later, perhaps against some C code. #94348

I'm not sure if my changes to contains_extern_indicator are correct,
they appear to be doing the right thing and letting the functions through to
LLVM, but I'm not sure if they're doing too much.

I'm also completely lost at what to do for the gcc codegen backend.

This also still needs the lint for being placed on a generic function (unless that should just error),
and I'm not sure if no_mangle should also add to used_globals.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 26, 2022
@rust-highfive
Copy link
Collaborator

Some changes occured to rustc_codegen_gcc

cc @antoyo

@rust-highfive
Copy link
Collaborator

r? @jackh726

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 26, 2022
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.debug-assertions := True
configure: rust.overflow-checks := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 
---
   Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
    Finished release [optimized] target(s) in 8.64s
tidy check
tidy: Skipping binary file check, read-only filesystem
tidy error: following path contains more than 985 entries, you should move the test to some relevant subdirectory (current: 986): /checkout/src/test/ui
* 629 error codes
* highest error code: E0787
Found 504 error codes
Found 0 error(s) in error codes
Found 0 error(s) in error codes
Done!
tidy error: /checkout/src/test/codegen/used_on_fn_def.rs: too many trailing newlines (2)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: Zero }', src/tools/tidy/src/features.rs:387:32
Build completed unsuccessfully in 0:00:11

@bjorn3
Copy link
Member

bjorn3 commented Mar 26, 2022

This is useful when writing a functions as a library to be linked in later, perhaps against some C code.

Why is #[no_mangle] not enough? That should cause the function to be exported from the linked library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants