Skip to content

Commit e492429

Browse files
[freebsd] fix the freebsd build (#116)
I wanted to verify some Linux-specific changes don't break other platforms and found that ds2 doesn't currently build on FreeBSD 14.0. These patches address the issues encountered. The most noteworthy change is the addition of `file(MAKE_DIRECTORY)` calls to the `RegsGen2` steps. This step was failing on FreeBSD because the directories did not already exist. Not sure why it succeeds on other platforms, but the `MAKE_DIRECTORY` addition should be harmless when not needed. ### Validation Built on VM running 14.0-RELEASE-p10. Launched ds2 on FreeBSD in platform mode, verified lldb can connect. Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
1 parent 5b6f4a8 commit e492429

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "X86" OR
7979
CMAKE_SYSTEM_PROCESSOR MATCHES "i[3-6]86")
8080
set(DS2_ARCHITECTURE X86)
8181
elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "X64" OR
82-
CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|x86_64")
82+
CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|AMD64|x86_64")
8383
set(DS2_ARCHITECTURE X86_64)
8484
elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "RISCV32|RISCV64|RISCV128" OR
8585
CMAKE_SYSTEM_PROCESSOR MATCHES "riscv32|riscv64|riscv128")
@@ -140,25 +140,29 @@ else()
140140
endif()
141141

142142
foreach(ARCH ARM ARM64 RISCV32 RISCV64 RISCV128 X86 X86_64)
143+
set(ArchHeadersDir ${CMAKE_CURRENT_BINARY_DIR}/Headers/DebugServer2/Architecture/${ARCH})
144+
file(MAKE_DIRECTORY ${ArchHeadersDir})
143145
add_custom_command(OUTPUT
144-
${CMAKE_CURRENT_BINARY_DIR}/Headers/DebugServer2/Architecture/${ARCH}/RegistersDescriptors.h
146+
${ArchHeadersDir}/RegistersDescriptors.h
145147
COMMAND
146148
$<TARGET_FILE:RegsGen2::RegsGen2>
147149
-a ${RegsGenOS}
148150
-I DebugServer2/Architecture/RegisterLayout.h
149-
-h -o ${CMAKE_CURRENT_BINARY_DIR}/Headers/DebugServer2/Architecture/${ARCH}/RegistersDescriptors.h
151+
-h -o ${ArchHeadersDir}/RegistersDescriptors.h
150152
-f "${PROJECT_SOURCE_DIR}/Definitions/${ARCH}.json"
151153
DEPENDS
152154
Definitions/${ARCH}.json
153155
RegsGen2::RegsGen2)
154156

157+
set(ArchSourcesDir ${CMAKE_CURRENT_BINARY_DIR}/Sources/Architecture/${ARCH})
158+
file(MAKE_DIRECTORY ${ArchSourcesDir})
155159
add_custom_command(OUTPUT
156-
${CMAKE_CURRENT_BINARY_DIR}/Sources/Architecture/${ARCH}/RegistersDescriptors.cpp
160+
${ArchSourcesDir}/RegistersDescriptors.cpp
157161
COMMAND
158162
$<TARGET_FILE:RegsGen2::RegsGen2>
159163
-a ${RegsGenOS}
160164
-I DebugServer2/Architecture/${ARCH}/RegistersDescriptors.h
161-
-c -o ${CMAKE_CURRENT_BINARY_DIR}/Sources/Architecture/${ARCH}/RegistersDescriptors.cpp
165+
-c -o ${ArchSourcesDir}/RegistersDescriptors.cpp
162166
-f "${PROJECT_SOURCE_DIR}/Definitions/${ARCH}.json"
163167
DEPENDS
164168
Definitions/${ARCH}.json

Sources/Utils/POSIX/FaultHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FaultHandler {
3131
}
3232

3333
void installCatcher() {
34-
#if defined(__APPLE__)
34+
#if defined(__APPLE__) || defined(__FreeBSD__)
3535
long sz = SIGSTKSZ;
3636
#elif defined(__ANDROID__)
3737
long sz = MINSIGSTKSZ;

Tools/JSObjects/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ target_include_directories(jsobjects PRIVATE
4949
${JSObjects_SOURCE_DIR}/Sources/libjson
5050
${JSObjects_BINARY_DIR})
5151

52+
if("${BSD}" STREQUAL "FreeBSD")
53+
target_compile_definitions(jsobjects PRIVATE
54+
_XOPEN_SOURCE=600)
55+
endif()
56+
5257
if((CMAKE_C_COMPILER_ID MATCHES "GNU" AND
5358
CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.6) OR
5459
((CMAKE_C_COMPILER_ID MATCHES "Clang" AND

0 commit comments

Comments
 (0)