Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 6783052

Browse files
committed
CMake: add target generate_syscall_intercept_scoped
In intermediary target to fix parallel builds. Two targets depend on syscall_intercept_scoped.o, and apparently in parallel builds CMake often executed the commands twice, which sometimes resulted in a failing builds. An example of such build failure: ``` [ 83%] Built target syscall_intercept_unscoped [ 83%] Hiding symbols [ 84%] Hiding symbols /usr/bin/objcopy: error: the input file 'syscall_intercept_scoped.o' is empty CMakeFiles/syscall_intercept_static.dir/build.make:61: recipe for target 'syscall_intercept_scoped.o' failed make[2]: *** [syscall_intercept_scoped.o] Error 1 ``` Adding a custom_target hopefully makes things better. See also: https://cmake.org/Bug/view.php?id=10082
1 parent 6fbb015 commit 6783052

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

CMakeLists.txt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,29 @@ add_library(syscall_intercept_unscoped STATIC
103103
set(syscall_intercept_unscoped_a $<TARGET_FILE:syscall_intercept_unscoped>)
104104

105105
add_custom_command(
106-
OUTPUT syscall_intercept_scoped.o
106+
OUTPUT syscall_intercept_unscoped.o
107107
COMMAND ${CMAKE_LINKER}
108108
-r --whole-archive ${syscall_intercept_unscoped_a}
109-
-o syscall_intercept_scoped.o
110-
COMMAND ${CMAKE_OBJCOPY} --localize-hidden syscall_intercept_scoped.o
111-
COMMENT "Hiding symbols")
109+
-o syscall_intercept_unscoped.o
110+
DEPENDS syscall_intercept_unscoped)
111+
112+
add_custom_command(
113+
OUTPUT syscall_intercept_scoped.o
114+
COMMAND ${CMAKE_OBJCOPY}
115+
--localize-hidden
116+
syscall_intercept_unscoped.o
117+
syscall_intercept_scoped.o
118+
DEPENDS syscall_intercept_unscoped.o)
119+
120+
add_custom_target(generate_syscall_intercept_scoped
121+
DEPENDS syscall_intercept_scoped.o)
112122

113123
add_library(syscall_intercept_shared SHARED syscall_intercept_scoped.o)
114124
add_library(syscall_intercept_static STATIC syscall_intercept_scoped.o)
115125

126+
add_dependencies(syscall_intercept_shared generate_syscall_intercept_scoped)
127+
add_dependencies(syscall_intercept_static generate_syscall_intercept_scoped)
128+
116129
set_target_properties(syscall_intercept_base_c
117130
PROPERTIES C_VISIBILITY_PRESET hidden)
118131

0 commit comments

Comments
 (0)