Skip to content

Instantly share code, notes, and snippets.

@bhamiltoncx
Created December 21, 2023 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhamiltoncx/83895a77882c96c081d200cf37505036 to your computer and use it in GitHub Desktop.
Save bhamiltoncx/83895a77882c96c081d200cf37505036 to your computer and use it in GitHub Desktop.
Repro for clang GMLT + LTO missing C++ namespace info
% clang++ --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
% cat test.cc
#include <stdio.h>
namespace foo {
__attribute__((noinline))
void f() {
printf("yay\n");
}
__attribute__((always_inline)) void g() {
f();
}
void h() {
g();
};
} // namespace foo
int main(int argc, char** argv) {
foo::h();
}
% clang++ -gmlt -Os -flto -std=c++17 -c -o test.o test.cc
% clang++ -gmlt -Os -flto -Wl,-object_path_lto,lto.o -o test test.o
% dsymutil test
% dwarfdump test.dSYM/Contents/Resources/DWARF/test
test.dSYM/Contents/Resources/DWARF/test: file format Mach-O arm64
.debug_info contents:
0x00000000: Compile Unit: length = 0x00000094, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000098)
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("Apple clang version 15.0.0 (clang-1500.0.40.1)")
DW_AT_language (DW_LANG_C_plus_plus_14)
DW_AT_name ("test.cc")
DW_AT_LLVM_sysroot ("/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
DW_AT_APPLE_sdk ("MacOSX.sdk")
DW_AT_stmt_list (0x00000000)
DW_AT_comp_dir ("/Users/benhamilton")
DW_AT_APPLE_optimized (true)
DW_AT_low_pc (0x0000000100003f6c)
DW_AT_high_pc (0x0000000100003f90)
0x00000032: DW_TAG_subprogram
DW_AT_low_pc (0x0000000100003f6c)
DW_AT_high_pc (0x0000000100003f78)
DW_AT_APPLE_omit_frame_ptr (true)
DW_AT_call_all_calls (true)
DW_AT_name ("f")
0x00000043: DW_TAG_subprogram
DW_AT_name ("g")
DW_AT_inline (DW_INL_inlined)
0x00000049: DW_TAG_subprogram
DW_AT_name ("h")
DW_AT_inline (DW_INL_inlined)
0x0000004f: DW_TAG_subprogram
DW_AT_low_pc (0x0000000100003f78)
DW_AT_high_pc (0x0000000100003f90)
DW_AT_call_all_calls (true)
DW_AT_name ("main")
0x00000060: DW_TAG_inlined_subroutine
DW_AT_abstract_origin (0x0000000000000049 "h")
DW_AT_low_pc (0x0000000100003f80)
DW_AT_high_pc (0x0000000100003f84)
DW_AT_call_file ("/Users/benhamilton/test.cc")
DW_AT_call_line (21)
DW_AT_call_column (0x03)
0x00000074: DW_TAG_inlined_subroutine
DW_AT_abstract_origin (0x0000000000000043 "g")
DW_AT_low_pc (0x0000000100003f80)
DW_AT_high_pc (0x0000000100003f84)
DW_AT_call_file ("/Users/benhamilton/test.cc")
DW_AT_call_line (15)
DW_AT_call_column (0x03)
0x00000088: NULL
0x00000089: DW_TAG_call_site
DW_AT_call_origin (0x00000032)
DW_AT_call_return_pc (0x0000000100003f84)
0x00000096: NULL
0x00000097: NULL
% nm test.dSYM/Contents/Resources/DWARF/test | c++filt
0000000100003f6c t foo::f()
0000000100000000 T __mh_execute_header
0000000100003f78 T _main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment