Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Weak alias to static function not working #17774

Open Quuxplusone opened 11 years ago

Quuxplusone commented 11 years ago
Bugzilla Link PR17775
Status NEW
Importance P normal
Reported by Scott Pakin (scott+llvm+bugzilla@pakin.org)
Reported on 2013-11-01 16:11:05 -0700
Last modified on 2021-04-01 07:44:10 -0700
Version trunk
Hardware PC Linux
CC dgregor@apple.com, dmajor@bugmail.cc, llvm-bugs@lists.llvm.org, lukebenes@hotmail.com, scott+llvm+bugzilla@pakin.org, thierry@FreeBSD.org, tstellar@redhat.com
Fixed by commit(s)
Attachments aliasing.cpp (200 bytes, text/x-c++src)
Blocks PR45309
Blocked by
See also
Created attachment 11473
Minimal reproducer for weak-alias problem

Weak aliases to unused static functions fail with an error message.  It looks
like the compiler is first removing the unused static function then complaining
that it can't create a weak alias to a function that no longer exists:

$ clang++ --version | head -1
clang version 3.4 (trunk)
$ clang++ -c aliasing.cpp
aliasing.cpp:8:56: error: alias must point to a defined variable or function
  const char* do_something (void) __attribute__((weak, alias("do_somethi...
                                                       ^
1 error generated.
$ g++ --version | head -1
g++ (GCC) 4.7.2
$ g++ -c aliasing.cpp

I'm seeing this problem with r193799, but I recall it working in r190315.  This
seems to be a C++ issue; analogous C code made it through clang with no
problems.

Defining do_something_original() as non-static in the attached file makes the
problem go away, but in my real code I'd prefer to have the function declared
static.

-- Scott
Quuxplusone commented 11 years ago

Attached aliasing.cpp (200 bytes, text/x-c++src): Minimal reproducer for weak-alias problem

Quuxplusone commented 4 years ago

This is still an issue in clang 10.0.0.

Quuxplusone commented 4 years ago

Relevant mailing list post: http://lists.llvm.org/pipermail/cfe-dev/2018-May/057870.html

Quuxplusone commented 4 years ago

openhpi 3.8.0 hits this bug: https://github.com/open-hpi/openhpi/releases/tag/3.8.0