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

Missing some symbol definitions in module build #125071

Open
hokein opened this issue Jan 30, 2025 · 2 comments
Open

Missing some symbol definitions in module build #125071

hokein opened this issue Jan 30, 2025 · 2 comments
Labels
clang:modules C++20 modules and Clang Header Modules

Comments

@hokein
Copy link
Collaborator

hokein commented Jan 30, 2025

Originally reported in https://issues.chromium.org/issues/390537876.

The minimal testcase is at https://github.com/hokein/module-bugs/tree/main/undefine

$ CLANG=/llvm-project/build-debug/bin/clang ./run.sh

$
... 
util.cc:(.text._Z1fv[_Z1fv]+0x5): undefined reference to `void x<int>()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)                  
@hokein hokein added the clang:modules C++20 modules and Clang Header Modules label Jan 30, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 30, 2025

@llvm/issue-subscribers-clang-modules

Author: Haojian Wu (hokein)

Originally reported in https://issues.chromium.org/issues/390537876.

The minimal testcase is at https://github.com/hokein/module-bugs/tree/main/undefine

$ CLANG=/llvm-project/build-debug/bin/clang ./run.sh

$
... 
util.cc:(.text._Z1fv[_Z1fv]+0x5): undefined reference to `void x&lt;int&gt;()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)                  

@hokein
Copy link
Collaborator Author

hokein commented Jan 30, 2025

Dumping the FD at the place

auto Loc = FD->getASTContext().getFullLoc(FD->getLocation());
:

FunctionDecl 0x55fabe132e20 <util.cc:3:1, line:5:1> line:3:5 main 'int ()'
`-CompoundStmt 0x55fabe1335f8 <col:12, line:5:1>
  `-CallExpr 0x55fabe1335d8 <line:4:3, col:5> 'void'
    `-ImplicitCastExpr 0x55fabe1335c0 <col:3> 'void (*)()' <FunctionToPointerDecay>
      `-DeclRefExpr 0x55fabe1330d0 <col:3> 'void ()' lvalue Function 0x55fabe132f70 'f' 'void ()'
FunctionDecl 0x55fabe132f70 <./hoge.h:5:1, col:29> col:13 imported in hoge hidden used f 'void ()' inline
`-CompoundStmt 0x55fabe133560 <col:17, col:29>
  `-CallExpr 0x55fabe133540 <col:19, col:26> 'void'
    `-ImplicitCastExpr 0x55fabe1334f8 <col:19, col:24> 'void (*)()' <FunctionToPointerDecay>
      `-DeclRefExpr 0x55fabe1330f0 <col:19, col:24> 'void ()' lvalue Function 0x55fabe1333e0 'x' 'void ()' (FunctionTemplate 0x55fabe133150 'x')
FunctionDecl 0x55fabe1333e0 <./shared_ptr2.h:4:1, col:12> col:6 imported in hoge hidden used x 'void ()' implicit_instantiation
`-TemplateArgument type 'int'
  `-BuiltinType 0x55fabe0d8e30 'int'

The x FunctionDecl is missing a function body, which causes the undefined symbol error in the linker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

No branches or pull requests

2 participants