This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix extern C for __sanitizer_annotate_contiguous_container() (for gcc)
ClosedPublic

Authored by azat on Dec 15 2020, 10:21 AM.

Details

Summary

gcc supports it only at the beginning:

$ g++ -o /dev/null -c /tmp/test_extern.cpp
$ cat /tmp/test_extern.cpp
extern "C" __attribute__ ((__visibility__("default"))) int foo();

Otherwise:

$ g++ -o /dev/null -c /tmp/test_extern.cpp
/tmp/test_extern.cpp:1:52: error: expected unqualified-id before string constant
    1 | __attribute__ ((__visibility__("default"))) extern "C" int foo();
      |                                                    ^~~
$ cat /tmp/test_extern.cpp
__attribute__ ((__visibility__("default"))) extern "C" int foo();

Diff Detail

Event Timeline

azat requested review of this revision.Dec 15 2020, 10:21 AM
azat created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2020, 10:21 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Dec 15 2020, 1:18 PM
This revision is now accepted and ready to land.Dec 15 2020, 1:18 PM

@azat What version of GCC are you using?

azat added a comment.Dec 15 2020, 2:10 PM

@azat What version of GCC are you using?

10.2

And it seems that gcc had been always rejecting it
Yes this can be fixed in gcc, but in the mean time this patch looks simple enough, and it will allow using libc++ with gcc sanitizers

P.S. I've just verified versions from 4.x to 10 and all of them reject it (on godbolt)

azat added a comment.Dec 16 2020, 1:12 AM

https://buildkite.com/llvm-project/diff-checks/builds/22546#42504dd5-9909-4d24-a94b-73413ec8839c

Please make sure you have the correct access rights
and the repository exists.')
INFO    Syncing local, origin and upstream...
INFO    Backing off reset_repository(...) for 2.4s (git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git push origin main
  stderr: 'ERROR: You must verify your email address.
See https://github.com/settings/emails.
 
fatal: Could not read from remote repository.

@ldionne interesting is this about my email? I've just checked and it wasn't verified indeed (it seems that this verification status had been reset during one of github vulnerabilities)

https://buildkite.com/llvm-project/diff-checks/builds/22546#42504dd5-9909-4d24-a94b-73413ec8839c

Please make sure you have the correct access rights
and the repository exists.')
INFO    Syncing local, origin and upstream...
INFO    Backing off reset_repository(...) for 2.4s (git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git push origin main
  stderr: 'ERROR: You must verify your email address.
See https://github.com/settings/emails.
 
fatal: Could not read from remote repository.

@ldionne interesting is this about my email? I've just checked and it wasn't verified indeed (it seems that this verification status had been reset during one of github vulnerabilities)

TBH, I don't know. It's the first time I see this. If you give me your Author Name <email@domain>, I can commit this for you.

azat added a comment.Dec 16 2020, 1:36 PM

TBH, I don't know. It's the first time I see this. If you give me your Author Name <email@domain>, I can commit this for you.

Azat Khuzhin <a3at.mail@gmail.com>

Thanks!

azat updated this revision to Diff 312385.Dec 16 2020, 11:17 PM

Update patch after github email was verified

In attempt to fix [1]:

  Please make sure you have the correct access rights
  and the repository exists.')
  INFO    Syncing local, origin and upstream...
  INFO    Backing off reset_repository(...) for 2.4s (git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
    cmdline: git push origin main
    stderr: 'ERROR: You must verify your email address.
  See https://github.com/settings/emails.
   
  fatal: Could not read from remote repository.

[1]: https://buildkite.com/llvm-project/diff-checks/builds/22546#42504dd5-9909-4d24-a94b-73413ec8839c