Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #427 from EOSIO/fix/mac_native_debug
Browse files Browse the repository at this point in the history
Fix/mac native debug
  • Loading branch information
larryk85 committed Feb 27, 2019
2 parents 056890e + d44b6ac commit 972c25c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion eosio_llvm
Submodule eosio_llvm updated 1 files
+1 −1 tools/lld
9 changes: 9 additions & 0 deletions modules/EosioCDTMacros.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,17 @@ macro (add_native_library TARGET)
endmacro()

macro (add_native_executable TARGET)
cmake_policy(SET CMP0002 OLD)
add_executable( ${TARGET} ${ARGN} )
target_compile_options( ${TARGET} PUBLIC -fnative )
set_target_properties( ${TARGET} PROPERTIES LINK_FLAGS "-fnative" SUFFIX "" )
get_target_property(BINOUTPUT ${TARGET} BINARY_DIR)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options( ${TARGET} PUBLIC -g )
find_program ( name NAMES "dsymutil" )
if ( name )
add_custom_command( TARGET ${TARGET} POST_BUILD COMMAND dsymutil ${BINOUTPUT}/${TARGET} )
endif()
endif()
endmacro()

2 changes: 1 addition & 1 deletion modules/TestsExternalProject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ExternalProject_Add(
EosioWasmTests
SOURCE_DIR "${CMAKE_SOURCE_DIR}/tests/unit"
BINARY_DIR "${CMAKE_BINARY_DIR}/tests/unit"
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/lib/cmake/eosio.cdt/EosioWasmToolchain.cmake -DEOSIO_CDT_BIN=${CMAKE_BINARY_DIR}/lib/cmake/eosio.cdt/ -DBASE_BINARY_DIR=${CMAKE_BINARY_DIR} -D__APPLE=${APPLE}
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/lib/cmake/eosio.cdt/EosioWasmToolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DEOSIO_CDT_BIN=${CMAKE_BINARY_DIR}/lib/cmake/eosio.cdt/ -DBASE_BINARY_DIR=${CMAKE_BINARY_DIR} -D__APPLE=${APPLE}
UPDATE_COMMAND ""
PATCH_COMMAND ""
TEST_COMMAND ""
Expand Down
14 changes: 1 addition & 13 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,5 @@ add_native_executable( print_tests print_tests.cpp )
add_native_executable( time_tests time_tests.cpp )
add_native_executable( varint_tests varint_tests.cpp )

add_dependencies( name_tests EosioTools )
add_dependencies( binary_extension_tests EosioTools )
add_dependencies( crypto_tests EosioTools )
add_dependencies( datastream_tests EosioTools )
add_dependencies( fixed_bytes_tests EosioTools )
add_dependencies( name_tests EosioTools )
add_dependencies( rope_tests EosioTools )
add_dependencies( serialize_tests EosioTools )
add_dependencies( symbol_tests EosioTools )
add_dependencies( system_tests EosioTools )
add_dependencies( time_tests EosioTools )
add_dependencies( varint_tests EosioTools )

target_compile_options( rope_tests PUBLIC -g )
add_subdirectory(test_contracts)
12 changes: 12 additions & 0 deletions tools/cc/eosio-cpp.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ int main(int argc, const char **argv) {
if ( !llvm::sys::fs::exists( opts.output_fn ) ) {
return -1;
}

// need to generate dSYM for mac OSX
#ifdef __APPLE__
if (opts.native) {
if (opts.debug) {
if (!eosio::cdt::environment::exec_subprogram("dsymutil", std::vector<std::string>{opts.output_fn}, true)) {
return -1;
}
}
}
#endif
}

return 0;
}
6 changes: 5 additions & 1 deletion tools/include/compiler_options.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ static cl::opt<bool> g_opt(
"g",
cl::desc("debug build <ignored>"),
cl::Hidden,
cl::ZeroOrMore,
cl::cat(EosioCompilerToolCategory));
static cl::opt<std::string> x_opt(
"x",
Expand Down Expand Up @@ -337,6 +338,7 @@ struct Options {
std::vector<std::string> ld_options;
std::vector<std::string> abigen_options;
std::vector<std::string> abigen_resources;
bool debug;
bool native;
};

Expand Down Expand Up @@ -459,6 +461,7 @@ static Options CreateOptions(bool add_defaults=true) {
std::vector<std::string> ldopts;
std::vector<std::string> agopts;
bool link = true;
bool debug = false;
std::string pp_dir;
std::string abigen_output;
std::string abigen_contract;
Expand All @@ -468,6 +471,7 @@ static Options CreateOptions(bool add_defaults=true) {
#else
bool abigen = abigen_opt;
abigen_output = abigen_output_opt;
debug = g_opt;
#endif

if (add_defaults) {
Expand Down Expand Up @@ -797,5 +801,5 @@ static Options CreateOptions(bool add_defaults=true) {
if (fuse_main_opt)
ldopts.emplace_back("-fuse-main");
#endif
return {output_fn, inputs, link, abigen, pp_dir, abigen_output, abigen_contract, copts, ldopts, agopts, agresources, fnative_opt};
return {output_fn, inputs, link, abigen, pp_dir, abigen_output, abigen_contract, copts, ldopts, agopts, agresources, debug, fnative_opt};
}

0 comments on commit 972c25c

Please sign in to comment.