Add first bits to cross-compile the runtime for OSX

Summary: Add first bits to cross-compile the runtime for OSX.

(cherry picked from FBD24330977)
This commit is contained in:
Alexander Shaposhnikov 2020-10-15 03:51:56 -07:00 committed by Maksim Panchenko
parent 0b6df06e04
commit bbd9d610fe
4 changed files with 33 additions and 0 deletions

View File

@ -30,3 +30,16 @@ target_include_directories(bolt_rt_hugify PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
install(TARGETS bolt_rt_instr DESTINATION lib)
install(TARGETS bolt_rt_hugify DESTINATION lib)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_library(bolt_rt_instr_osx STATIC
instr.cpp
${CMAKE_CURRENT_BINARY_DIR}/config.h
)
target_include_directories(bolt_rt_instr_osx PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_compile_options(bolt_rt_instr_osx PRIVATE
-target x86_64-apple-darwin19.6.0
-ffreestanding
-fno-exceptions
-fno-rtti)
install(TARGETS bolt_rt_instr_osx DESTINATION lib)
endif()

View File

@ -1,5 +1,7 @@
#if !defined(__APPLE__)
#include <cstddef>
#include <cstdint>
#endif
#include "config.h"
#ifdef HAVE_ELF_H
@ -44,6 +46,8 @@
"pop %%rbx\n" \
"pop %%rax\n"
#if !defined(__APPLE__)
// Anonymous namespace covering everything but our library entry point
namespace {
@ -327,3 +331,5 @@ inline uint64_t alignTo(uint64_t Value, uint64_t Align) {
return (Value + Align - 1) / Align * Align;
}
} // anonymous namespace
#endif

View File

@ -9,6 +9,8 @@
//
//===----------------------------------------------------------------------===//
#if !defined(__APPLE__)
#include "common.h"
#include <sys/mman.h>
@ -172,3 +174,5 @@ extern "C" __attribute((naked)) void __bolt_hugify_self() {
"jmp *__bolt_hugify_init_ptr(%%rip)\n"
:::);
}
#endif

View File

@ -57,6 +57,8 @@
{}
#endif
#if !defined(__APPLE__)
// Main counters inserted by instrumentation, incremented during runtime when
// points of interest (locations) in the program are reached. Those are direct
// calls and direct and indirect branches (local ones). There are also counters
@ -1460,3 +1462,11 @@ extern "C" void __bolt_instr_fini() {
__bolt_instr_data_dump();
DEBUG(report("Finished.\n"));
}
#else
// On OSX/iOS the final symbol name of an extern "C" function/variable contains
// one extra leading underscore: _bolt_instr_setup -> __bolt_instr_setup.
extern "C" __attribute((section("__TEXT,__setup"))) void _bolt_instr_setup() {}
#endif