-
Notifications
You must be signed in to change notification settings - Fork 1
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
error: declaration '__builtin_trap' attached to named module 'Invariant' can't be attached to other modules #3
Comments
Can you provide a reproducer or at best a minimal reproducer? |
BTW, the error message looks not like clangd's error message. If it is from the compiler, please register it in the upstream repo. |
Yes, that was from clang++ on this branch. I'll open an issue on llvm-project if I'm able to get a minimal reproducer, but so far my attempts at a minimal reproducer failed. |
Sorry, @chriselrod for ping, but did you create an issue in llvm-project? If yes, may you give an issue link please? Thanks for your attention. |
I failed to get a minimal reproducer, so I haven't created an issue yet. One of my dependencies was using these intrinsics, as well as some of my own code. By replacing all uses within my own code with explicitly typed versions (e.g. But then I got linker errors for some exported module functions. I made one attempt at a minimal reproducer for this, but it also worked fine. Something I didn't take advantage but probably should have are implementation units, to hide implementations.
|
Yeah, it is suggested to use implementation units to hide implementation more. There is also an option called reduced BMI to help that (https://clang.llvm.org/docs/StandardCPlusPlusModules.html#reduced-bmi). For rebuilding, there is a WIP in llvm/llvm-project#96453. But end users need the help from build systems to use that. For PCH + modules, technically it might be fine. But there is not so people tested it. And also personally, I feel it may not be necessary to do that. |
This patch adds a frame recognizer for Clang's `__builtin_verbose_trap`, which behaves like a `__builtin_trap`, but emits a failure-reason string into debug-info in order for debuggers to display it to a user. The frame recognizer triggers when we encounter a frame with a function name that begins with `__clang_trap_msg`, which is the magic prefix Clang emits into debug-info for verbose traps. Once such frame is encountered we display the frame function name as the `Stop Reason` and display that frame to the user. Example output: ``` (lldb) run warning: a.out was compiled with optimization - stepping may behave oddly; variables may not be available. Process 35942 launched: 'a.out' (arm64) Process 35942 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = Misc.: Function is not implemented frame #1: 0x0000000100003fa4 a.out`main [inlined] Dummy::func(this=<unavailable>) at verbose_trap.cpp:3:5 [opt] 1 struct Dummy { 2 void func() { -> 3 __builtin_verbose_trap("Misc.", "Function is not implemented"); 4 } 5 }; 6 7 int main() { (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = Misc.: Function is not implemented frame #0: 0x0000000100003fa4 a.out`main [inlined] __clang_trap_msg$Misc.$Function is not implemented$ at verbose_trap.cpp:0 [opt] * frame #1: 0x0000000100003fa4 a.out`main [inlined] Dummy::func(this=<unavailable>) at verbose_trap.cpp:3:5 [opt] frame #2: 0x0000000100003fa4 a.out`main at verbose_trap.cpp:8:13 [opt] frame #3: 0x0000000189d518b4 dyld`start + 1988 ```
This is a regression compared to clang 18.1.6 or llvm/llvm-project#66462.
My code calling
__builtin_trap()
no longer compiles with this branch ofclang++
.I am also getting this for modules that instantiate class templates declared/defined in other modules (when this worked with older versions of clang++).
The text was updated successfully, but these errors were encountered: