Skip to content

Commit 6e76af6

Browse files
snake66Greg LewisKurt Miller
committed
Add support for *BSD to makefiles
Updates the makefiles to set up for compilation and building for *BSD. This is a cleaned up diff towards the existing BSD port from the battleblow/jdk repository. Some parts have been held back for later PRs, mainly because I expect them to require more thorough review. (Some is also probably outdated, and we'll go through those first.) This work is sponsored by The FreeBSD Foundation. Co-authored-by: Greg Lewis <glewis@openjdk.org> Co-authored-by: Kurt Miller <bsdkurt@openjdk.org>
1 parent 8ee4b53 commit 6e76af6

26 files changed

+179
-16
lines changed

make/Hsdis.gmk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ ifeq ($(HSDIS_BACKEND), llvm)
6262
LLVM_OS := apple-darwin
6363
else ifeq ($(call isTargetOs, windows), true)
6464
LLVM_OS := pc-windows-msvc
65+
else ifeq ($(call isTargetOsEnv, bsd.freebsd), true)
66+
LLVM_OS := unknown-freebsd
6567
else
6668
$(error No support for LLVM on this platform)
6769
endif

make/RunTestsPrebuilt.gmk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ else
169169
OPENJDK_TARGET_OS := linux
170170
else ifeq ($(UNAME_OS), Darwin)
171171
OPENJDK_TARGET_OS := macosx
172+
else ifneq ($(findstring BSD,$(UNAME_OS)),)
173+
OPENJDK_TARGET_OS := bsd
172174
else
173175
OPENJDK_TARGET_OS := $(UNAME_OS)
174176
endif
@@ -214,6 +216,9 @@ ifeq ($(OPENJDK_TARGET_OS), linux)
214216
else ifeq ($(OPENJDK_TARGET_OS), macosx)
215217
NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu)
216218
MEMORY_SIZE := $(shell $(EXPR) `/usr/sbin/sysctl -n hw.memsize` / 1024 / 1024)
219+
else ifeq ($(OPENJDK_TARGET_OS), bsd)
220+
NUM_CORES := $(shell /sbin/sysctl -n hw.ncpu)
221+
MEMORY_SIZE := $(shell $(EXPR) `/sbin/sysctl -n hw.physmem` / 1024 / 1024)
217222
else ifeq ($(OPENJDK_TARGET_OS), windows)
218223
NUM_CORES := $(NUMBER_OF_PROCESSORS)
219224
MEMORY_SIZE := $(shell \

make/common/JdkNativeCompilation.gmk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ define AddJdkLibrary
234234
ifeq ($(call isTargetOs, aix)+$$($1_$2_MODULE):$$($1_$2_NAME), true+java.base:jli)
235235
$1_$2_STATIC_LIBRARY := true
236236
endif
237+
ifeq ($(call isTargetOsEnv, bsd.openbsd)+$$($1_$2_MODULE):$$($1_$2_NAME), true+java.base:jli)
238+
$1_$2_STATIC_LIBRARY := true
239+
$1_LIBS += $(LIBZ_LIBS) $(LIBPTHREAD)
240+
endif
237241
ifeq ($$($1_$2_MODULE):$$($1_$2_NAME), gtest:gtest)
238242
$1_$2_STATIC_LIBRARY := true
239243
endif

make/common/Utils.gmk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ isTargetOs = \
196196
isTargetOsType = \
197197
$(strip $(if $(filter $(OPENJDK_TARGET_OS_TYPE), $1), true, false))
198198

199+
isTargetOsEnv = \
200+
$(strip $(if $(filter $(OPENJDK_TARGET_OS_ENV), $1), true, false))
201+
199202
isTargetCpu = \
200203
$(strip $(if $(filter $(OPENJDK_TARGET_CPU), $1), true, false))
201204

make/common/modules/LauncherCommon.gmk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ define SetupBuildLauncherBody
182182
DISABLED_WARNINGS_clang := unused-function, \
183183
LDFLAGS := $$($1_LDFLAGS), \
184184
LDFLAGS_linux := $$(call SetExecutableOrigin,/../lib), \
185+
LDFLAGS_bsd := $$(call SetExecutableOrigin,/../lib), \
185186
LDFLAGS_macosx := $$(call SetExecutableOrigin,/../lib), \
186187
LDFLAGS_FILTER_OUT := $$($1_LDFLAGS_FILTER_OUT), \
187188
JDK_LIBS := $$($1_JDK_LIBS), \

make/common/native/Link.gmk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ define CreateDynamicLibraryOrExecutable
185185
$$($1_SYSROOT_LDFLAGS) -o $$($1_TARGET) $$($1_LD_OBJ_ARG) \
186186
$$($1_LIBS) $$($1_EXTRA_LIBS))
187187
ifeq ($$($1_CREATE_DEBUGINFO), true)
188-
ifeq ($(call isTargetOs, linux), true)
188+
ifeq ($(call isTargetOs, linux bsd), true)
189189
# This cannot be run separately since it updates the original target
190190
# file.
191191
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_create_debuginfo, \
@@ -206,14 +206,17 @@ define CreateDynamicLibraryOrExecutable
206206
$$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET))
207207
endif
208208
ifeq ($$($1_CREATE_DEBUGINFO), true)
209-
ifeq ($(call isTargetOs, linux), true)
209+
ifeq ($(call isTargetOs, linux bsd), true)
210210
# Run this after strip is called, since strip can sometimes mangle
211211
# the embedded debuglink, which we want to avoid.
212212
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_add_debuginfo_link, \
213213
$(CD) $$($1_SYMBOLS_DIR) && \
214214
$$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET))
215215
endif
216216
endif
217+
ifeq ($(OPENJDK_TARGET_OS_ENV), bsd.netbsd)
218+
/usr/sbin/paxctl +m $$@
219+
endif
217220
ifneq ($(MACOSX_CODESIGN_MODE), disabled)
218221
# Remove signature explicitly first to avoid warnings if the linker
219222
# added a default adhoc signature.

make/devkit/createAutoconfBundle.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ case `uname -s` in
5151
Linux)
5252
os=linux
5353
;;
54+
*BSD)
55+
os=bsd
56+
;;
5457
CYGWIN*)
5558
os=cygwin
5659
;;

make/devkit/createTidyBundle.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mkdir -p "$SRC_DIR/$BUILD_DIR"
5555
cd "$SRC_DIR/$BUILD_DIR"
5656

5757
case $OS_NAME in
58-
Linux|Darwin)
58+
Linux|Darwin|*BSD)
5959
echo "Building Tidy HTML5 for Unix-like platform ($OS_NAME)..."
6060

6161
CMAKE_ARCH_OPTIONS=""

make/hotspot/gensrc/GensrcAdlc.gmk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ ifeq ($(call check-jvm-feature, compiler2), true)
4545
else ifeq ($(call isBuildOs, windows), true)
4646
ADLC_CFLAGS := -nologo -EHsc
4747
ADLC_CFLAGS_WARNINGS := -W3 -D_CRT_SECURE_NO_WARNINGS
48+
else ifeq ($(call isBuildOs, bsd), true)
49+
ADLC_CFLAGS := -fno-exceptions -D_ALLBSD_SOURCE=1 -D_BSDONLY_SOURCE
4850
endif
4951

5052
# Set the C++ standard
@@ -106,6 +108,8 @@ ifeq ($(call check-jvm-feature, compiler2), true)
106108
ifeq ($(HOTSPOT_TARGET_CPU_ARCH), aarch64)
107109
ADLCFLAGS += -DR18_RESERVED
108110
endif
111+
else ifeq ($(call isTargetOs, bsd), true)
112+
ADLCFLAGS += -D_ALLBSD_SOURCE=1 -D_BSDONLY_SOURCE
109113
else ifeq ($(call isTargetOs, windows), true)
110114
ADLCFLAGS += -D_WIN64=1
111115
ifeq ($(HOTSPOT_TARGET_CPU_ARCH), aarch64)

make/hotspot/gensrc/GensrcDtrace.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ifeq ($(INCLUDE), true)
3232

3333
ifeq ($(call check-jvm-feature, dtrace), true)
3434

35-
ifeq ($(call isTargetOs, macosx), true)
35+
ifeq ($(call isTargetOs, macosx bsd), true)
3636
DTRACE_CPP_FLAGS := -D_LP64 -x c
3737
else ifeq ($(call isTargetOs, linux), true)
3838
DTRACE_CPP_FLAGS := -x c

0 commit comments

Comments
 (0)