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

Suppress new profiler_builtins warning since LLVM 11 #76224

Closed

Conversation

richkadel
Copy link
Contributor

@richkadel richkadel commented Sep 1, 2020

GCC is emitting a new warning while building profiler_builtins with gcc. This should suppress that warning.

r? @cuviper

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 1, 2020
@richkadel
Copy link
Contributor Author

@tmandry FYI

@richkadel
Copy link
Contributor Author

@cuviper - I updated the PR description to reflect the change made as recommended by @tmiasko .

This is now basically a one-liner.

PTAL... Thanks!

@cuviper
Copy link
Member

cuviper commented Sep 2, 2020

It looks like that warning flag was fairly recently added in this commit (gcc-9.1.0), so it's definitely better conditionally.

However, I think this should probably be fixed in LLVM:

https://reviews.llvm.org/D82253
https://github.com/rust-lang/llvm-project/blob/45790d79496be37fbce6ec57abad5af8fa7a34d7/compiler-rt/lib/profile/GCDAProfiling.c#L631-L640

#ifndef _WIN32
// __attribute__((destructor)) and destructors whose priorities are greater than
// 100 run before this function and can thus be tracked. The priority is
// compatible with GCC 7 onwards.
__attribute__((destructor(100)))
#endif
static void llvm_writeout_and_clear(void) {
  llvm_writeout_files();
  fn_list_remove(&writeout_fn_list);
}

It sounds like the intent was to avoid this warning, but I think it would actually need to start at 101. Digging in GCC history, MAX_RESERVED_INIT_PRIORITY has always been 100, and the warning was added here (gcc-4.3.0) for <= MAX. I'm not sure where GCC 7 comes in though...

cc @MaskRay

@cuviper
Copy link
Member

cuviper commented Sep 2, 2020

For more context, here is how the warning is documented in the manpage as of GCC 10.2:

   -Wno-prio-ctor-dtor                                                    
       Do not warn if a priority from 0 to 100 is used for constructor or 
       destructor.  The use of constructor and destructor attributes allow
       you to assign a priority to the constructor/destructor to control  
       its order of execution before "main" is called or after it returns.
       The priority values must be greater than 100 as the compiler       
       reserves priority values between 0--100 for the implementation.    

@richkadel
Copy link
Contributor Author

@cuviper - I agree there should be a fix in LLVM, but until then, Rust builds (with profiler=true) are not clean. This is creating multiple occurrences of yellow warning messages during builds. (Very distracting, and unnecessary.) Most other warnings are suppressed in Rust builds.

This is a stopgap solution, not knowing how long it will take to resolve upstream.

Are you OK with this?

@cuviper
Copy link
Member

cuviper commented Sep 2, 2020

I have also filed https://bugs.llvm.org/show_bug.cgi?id=47399, so let's give that a chance for response. If it's really as simple as raising this priority to 101, we can patch that rather than papering over it.

@MaskRay
Copy link
Contributor

MaskRay commented Sep 2, 2020

It sounds like the intent was to avoid this warning, but I think it would actually need to start at 101. Digging in GCC history, MAX_RESERVED_INIT_PRIORITY has always been 100, and the warning was added here (gcc-4.3.0) for <= MAX. I'm not sure where GCC 7 comes in though...

No. __attribute__((desctructor(100))) is correct. The intention is that .fini_array.00101 can be recorded while .fini_array.00100 and .fini_array.00099 can't.

The patch can suppress GCC>=9 -Wprio-ctor-dtor warning but GCC 8 still warns

--- i/compiler-rt/lib/profile/GCDAProfiling.c
+++ w/compiler-rt/lib/profile/GCDAProfiling.c
@@ -628,6 +628,9 @@ void llvm_writeout_files(void) {
   }
 }
 
+#if defined(__GNUC__) && __GNUC__ >= 9
+#pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
+#endif
 #ifndef _WIN32
 // __attribute__((destructor)) and destructors whose priorities are greater than
 // 100 run before this function and can thus be tracked. The priority is

@cuviper
Copy link
Member

cuviper commented Sep 2, 2020

Well, pragma-masking this function on GCC 9 is an improvement, more focused than Rust doing it from the command line. @MaskRay are you going to make this change on the LLVM side?

@MaskRay
Copy link
Contributor

MaskRay commented Sep 2, 2020

Well, pragma-masking this function on GCC 9 is an improvement, more focused than Rust doing it from the command line. @MaskRay are you going to make this change on the LLVM side?

Yes. Suppressed GCC 9 -Wprio-ctor-dtor in llvm/llvm-project@1cfde14

@richkadel
Copy link
Contributor Author

@cuviper will you be updating the Rust fork with this fix?

@cuviper
Copy link
Member

cuviper commented Sep 4, 2020

@richkadel In the LLVM bug, I've asked for the patch to be backported to the 11.x branch. If you'd like to see it sooner, you can follow our backport procedure and I'll approve those PRs.
https://rustc-dev-guide.rust-lang.org/backend/updating-llvm.html#bugfix-updates

richkadel added a commit to richkadel/llvm-project that referenced this pull request Sep 4, 2020
…d write_string/length_of_string

The `__attribute__((destructor(100)))` diagnostic does not have a
warning option in GCC 8 (before r264853) and thus cannot be suppressed.

--

ported from llvm/llvm-project fix:

llvm@1cfde14

https://bugs.llvm.org/show_bug.cgi?id=47399

(Fixes problem behind rust-lang/rust#76224)
cuviper pushed a commit to rust-lang/llvm-project that referenced this pull request Sep 4, 2020
#73)

…d write_string/length_of_string

The `__attribute__((destructor(100)))` diagnostic does not have a
warning option in GCC 8 (before r264853) and thus cannot be suppressed.

--

ported from llvm/llvm-project fix:

llvm@1cfde14

https://bugs.llvm.org/show_bug.cgi?id=47399

(Fixes problem behind rust-lang/rust#76224)
@richkadel
Copy link
Contributor Author

This PR is no longer needed as of:

rust-lang/llvm-project#73 and #76341

@richkadel richkadel closed this Sep 6, 2020
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants