-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Code generation for inline Clang functions #5405
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
Comments
This was referenced May 2, 2025
github-merge-queue bot
pushed a commit
that referenced
this issue
May 9, 2025
This shows that `inline` is ignored and the function definition is not generated. Demo: ```c++ // hello_world.h inline void hello_world() {} ``` ```carbon // main.carbon library "Main"; import Cpp library "hello_world.h"; fn Run() -> i32 { Cpp.hello_world(); return 0; } ``` ```shell $ bazel-bin/toolchain/carbon compile main.carbon $ bazel-bin/toolchain/carbon link main.o --output=demo ld.lld: error: undefined symbol: hello_world() >>> referenced by main.carbon:8 >>> main.o:(main) error: linker command failed with exit code 1 (use -v to see invocation) ``` Part of #5405.
github-merge-queue bot
pushed a commit
that referenced
this issue
May 21, 2025
This requires: * Making `FunctionDecl` mutable since generating code (`HandleTopLevelDecl()`) requires a mutable declaration and since we manually add `used` attribute to force code generation. * Passing the file system to `Lower` since it's needed by Clang code generation. * Creating an internal Clang LLVM module and link it against the Carbon LLVM module. Demo: ```c++ // hello_world.h extern int puts; inline void hello_world() { ((int (*)(const char*))&puts)("hello world"); } ``` ```carbon // main.carbon library "Main"; import Cpp library "hello_world.h"; fn Run() -> i32 { Cpp.hello_world(); return 0; } ``` ```shell $ bazel-bin/toolchain/carbon compile main.carbon $ bazel-bin/toolchain/carbon link main.o --output=demo $ ./demo hello world ``` Based on #5406. Part of #5405.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: