[llvm-bugs] [Bug 48501] New: Clang emits __attribute__((__used__)) functions in submodules that weren't imported
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Dec 14 01:39:04 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48501
Bug ID: 48501
Summary: Clang emits __attribute__((__used__)) functions in
submodules that weren't imported
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Modules
Assignee: unassignedclangbugs at nondot.org
Reporter: teemperor at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
The example below reproduces the bug. 'use.h' is never actually imported by
main.cpp, but as it's in the same top-level module as 'other.h', the
'call_undefined' function is still deserialised and emitted. Note that this
happens with local-submodule-visibility turned on and off (at least with LSV=on
this seems like a bug):
$ cat main.cpp
#include "other.h"
int main() {}
$ cat other.h
struct Foo {
};
$ cat use.h
int undefined();
__attribute__((__used__))
inline int call_undefined() { undefined(); }
$ cat module.modulemap
module A {
module Use { header "use.h" export * }
module Other { header "other.h" export * }
}
$ clang main.cpp -fmodules -fcxx-modules -Rmodule-build
-fmodules-cache-path=pcms -Xclang -fmodules-local-submodule-visibility
Undefined symbols for architecture x86_64:
"undefined()", referenced from:
call_undefined() in main-fe42f9.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ clang main.cpp -fmodules -fcxx-modules -Rmodule-build
-fmodules-cache-path=pcms -Xclang -fmodules-local-submodule-visibility -S
-emit-llvm -o - | grep undefined
@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()*
@_Z14call_undefinedv to i8*)], section "llvm.metadata"
define linkonce_odr i32 @_Z14call_undefinedv() #0 {
%2 = call i32 @_Z9undefinedv()
declare i32 @_Z9undefinedv() #1
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201214/a31b5f96/attachment.html>
More information about the llvm-bugs
mailing list