Skip to content
This repository was archived by the owner on Aug 23, 2020. It is now read-only.

Commit 22c1198

Browse files
authored
Merge pull request EOSIO#427 from EOSIO/fix/mac_native_debug
Fix/mac native debug
2 parents a5ccf5f + 082ad5b commit 22c1198

File tree

6 files changed

+29
-16
lines changed

6 files changed

+29
-16
lines changed

eosio_llvm

modules/EosioCDTMacros.cmake.in

+9
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,17 @@ macro (add_native_library TARGET)
3333
endmacro()
3434

3535
macro (add_native_executable TARGET)
36+
cmake_policy(SET CMP0002 OLD)
3637
add_executable( ${TARGET} ${ARGN} )
3738
target_compile_options( ${TARGET} PUBLIC -fnative )
3839
set_target_properties( ${TARGET} PROPERTIES LINK_FLAGS "-fnative" SUFFIX "" )
40+
get_target_property(BINOUTPUT ${TARGET} BINARY_DIR)
41+
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
42+
target_compile_options( ${TARGET} PUBLIC -g )
43+
find_program ( name NAMES "dsymutil" )
44+
if ( name )
45+
add_custom_command( TARGET ${TARGET} POST_BUILD COMMAND dsymutil ${BINOUTPUT}/${TARGET} )
46+
endif()
47+
endif()
3948
endmacro()
4049

modules/TestsExternalProject.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ExternalProject_Add(
66
EosioWasmTests
77
SOURCE_DIR "${CMAKE_SOURCE_DIR}/tests/unit"
88
BINARY_DIR "${CMAKE_BINARY_DIR}/tests/unit"
9-
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}
9+
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}
1010
UPDATE_COMMAND ""
1111
PATCH_COMMAND ""
1212
TEST_COMMAND ""

tests/unit/CMakeLists.txt

+1-13
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,5 @@ add_native_executable( print_tests print_tests.cpp )
1616
add_native_executable( time_tests time_tests.cpp )
1717
add_native_executable( varint_tests varint_tests.cpp )
1818

19-
add_dependencies( name_tests EosioTools )
20-
add_dependencies( binary_extension_tests EosioTools )
21-
add_dependencies( crypto_tests EosioTools )
22-
add_dependencies( datastream_tests EosioTools )
23-
add_dependencies( fixed_bytes_tests EosioTools )
24-
add_dependencies( name_tests EosioTools )
25-
add_dependencies( rope_tests EosioTools )
26-
add_dependencies( serialize_tests EosioTools )
27-
add_dependencies( symbol_tests EosioTools )
28-
add_dependencies( system_tests EosioTools )
29-
add_dependencies( time_tests EosioTools )
30-
add_dependencies( varint_tests EosioTools )
31-
19+
target_compile_options( rope_tests PUBLIC -g )
3220
add_subdirectory(test_contracts)

tools/cc/eosio-cpp.cpp.in

+12
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ int main(int argc, const char **argv) {
241241
if ( !llvm::sys::fs::exists( opts.output_fn ) ) {
242242
return -1;
243243
}
244+
245+
// need to generate dSYM for mac OSX
246+
#ifdef __APPLE__
247+
if (opts.native) {
248+
if (opts.debug) {
249+
if (!eosio::cdt::environment::exec_subprogram("dsymutil", std::vector<std::string>{opts.output_fn}, true)) {
250+
return -1;
251+
}
252+
}
253+
}
254+
#endif
244255
}
256+
245257
return 0;
246258
}

tools/include/compiler_options.hpp.in

+5-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ static cl::opt<bool> g_opt(
147147
"g",
148148
cl::desc("debug build <ignored>"),
149149
cl::Hidden,
150+
cl::ZeroOrMore,
150151
cl::cat(EosioCompilerToolCategory));
151152
static cl::opt<std::string> x_opt(
152153
"x",
@@ -337,6 +338,7 @@ struct Options {
337338
std::vector<std::string> ld_options;
338339
std::vector<std::string> abigen_options;
339340
std::vector<std::string> abigen_resources;
341+
bool debug;
340342
bool native;
341343
};
342344

@@ -459,6 +461,7 @@ static Options CreateOptions(bool add_defaults=true) {
459461
std::vector<std::string> ldopts;
460462
std::vector<std::string> agopts;
461463
bool link = true;
464+
bool debug = false;
462465
std::string pp_dir;
463466
std::string abigen_output;
464467
std::string abigen_contract;
@@ -468,6 +471,7 @@ static Options CreateOptions(bool add_defaults=true) {
468471
#else
469472
bool abigen = abigen_opt;
470473
abigen_output = abigen_output_opt;
474+
debug = g_opt;
471475
#endif
472476

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

0 commit comments

Comments
 (0)