Page MenuHomePhabricator

Add support for LLVM profile for NetBSD
ClosedPublic

Authored by krytarowski on Dec 21 2018, 4:20 AM.

Details

Summary

NetBSD uses typical UNIX interfaces.

All tests pass except instrprof-dlopen-dlclose-gcov.test, as there
is not supported semantics of atexit(3) in dlopen(3)ed+dlclose(3)d
DSO.

NetBSD also ships an older version of LLVM profile (ABI v.2 predating
ABI v.4 in upstream version) inside libc. That copy has been manually
removed during the porting and testing process of the upstream version
to NetBSD. Otherwise there were conflicts between them two.

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Dec 21 2018, 4:20 AM

@joerg I was trying to change atexit(3) calls to C++ destructors or GCC destructiors (__attribute__((destructor))), but none of that worked.

For the former:

/public/llvm-build/lib/clang/8.0.0/lib/netbsd/libclang_rt.profile-x86_64.a(InstrProfilingRuntime.cc.o): In function `__clang_call_terminate':
InstrProfilingRuntime.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x2): undefined reference to `__cxa_begin_catch'
InstrProfilingRuntime.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x7): undefined reference to `std::terminate()'
/public/llvm-build/lib/clang/8.0.0/lib/netbsd/libclang_rt.profile-x86_64.a(InstrProfilingRuntime.cc.o):(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

For the latter hangs and crashes of many/all tests.

vsk added a comment.Dec 21 2018, 8:36 PM

Thanks, this patch lgtm.

@joerg I was trying to change atexit(3) calls to C++ destructors or GCC destructiors (__attribute__((destructor))), but none of that worked.

For the former:

/public/llvm-build/lib/clang/8.0.0/lib/netbsd/libclang_rt.profile-x86_64.a(InstrProfilingRuntime.cc.o): In function `__clang_call_terminate':
InstrProfilingRuntime.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x2): undefined reference to `__cxa_begin_catch'
InstrProfilingRuntime.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x7): undefined reference to `std::terminate()'
/public/llvm-build/lib/clang/8.0.0/lib/netbsd/libclang_rt.profile-x86_64.a(InstrProfilingRuntime.cc.o):(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

For the latter hangs and crashes of many/all tests.

Looks like you're missing the C++ runtime (libcxxabi or libcxx, IIRC, although you may be using libstdc++)?

In D55997#1340069, @vsk wrote:

Thanks, this patch lgtm.

@joerg I was trying to change atexit(3) calls to C++ destructors or GCC destructiors (__attribute__((destructor))), but none of that worked.

For the former:

/public/llvm-build/lib/clang/8.0.0/lib/netbsd/libclang_rt.profile-x86_64.a(InstrProfilingRuntime.cc.o): In function `__clang_call_terminate':
InstrProfilingRuntime.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x2): undefined reference to `__cxa_begin_catch'
InstrProfilingRuntime.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x7): undefined reference to `std::terminate()'
/public/llvm-build/lib/clang/8.0.0/lib/netbsd/libclang_rt.profile-x86_64.a(InstrProfilingRuntime.cc.o):(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

For the latter hangs and crashes of many/all tests.

Looks like you're missing the C++ runtime (libcxxabi or libcxx, IIRC, although you may be using libstdc++)?

I will defer for now this to @joerg to find an atexit(3) replacement to fix instrprof-dlopen-dlclose-gcov.test.

This revision was not accepted when it landed; it landed in state Needs Review.Dec 21 2018, 11:00 PM
Closed by commit rCRT349994: Add support for LLVM profile for NetBSD (authored by kamil, committed by ). · Explain Why
This revision was automatically updated to reflect the committed changes.