This is the minimal copy and paste version to get something running on Darwin.
Note the file platfrom_defs.h.inc. The section name has a ',' because of Mach-O. The section attribute length can be at most 16 characters. Thus, I had to remove the llvm part of the name.
The objcopy changes are beyond my me.
It stills fails the liniting. It claims that stddef.h and stdint.h are system headers. stddef.h and stdint.h are provided by the libc and the resource directory of clang ...
This is probably OK as a compromise. Few points around this:
// entrypoint.h #define ENTRYPOINT_DECL extern "C" namespace __llvm_libc { ENTRYPOINT_DECL <ret_type> entrypoint(<argl list>); } // namespace __llvm_libc// entrypoint.cpp #include "entrypoint.h" namespace __llvm_libc { <ret_type> entrypoint(<arg list>) { ... } } // namespace __llvm_libcThis gives you a C symbol but requires scope qualification in the callers from within LLVM libc. Exactly what we want.