Skip to content

Commit aef16fc

Browse files
committed
build: remove certctl requirement for host OpenSSL libs on macOS
Some platforms, like macOS, do not expose headers for the system's libcrypto for public consumption. libcrypto is relatively heavy and needs to know, e.g., the host system's endianness, so we scope the build down to macOS where OpenSSL headers are known to not be present and we can be reasonably certain that most of the systems today that would be cross-building are little endian. We still don't bother if building WITHOUT_OPENSSL since the end result is expected to be used by OpenSSL, but perhaps we could revisit that independently in case one, e.g., brings their own implementation. Reported by: jrtc27 Reviewed by: jrtc27, ngie Fixes: c340ef2 ("certctl: Reimplement in C") Differential Revision: https://reviews.freebsd.org/D51935
1 parent cb3eac9 commit aef16fc

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

Makefile.inc1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2709,8 +2709,14 @@ _basic_bootstrap_tools+=sbin/md5
27092709
_basic_bootstrap_tools+=usr.sbin/tzsetup
27102710
.endif
27112711

2712-
# certctl is needed as an install tool
2712+
# certctl is needed as an install tool. libcrypto is rather heavy, so we'll
2713+
# build that alongside it only for platforms that don't expose headers for
2714+
# OpenSSL, like macOS.
27132715
.if ${MK_CAROOT} != "no" && ${MK_OPENSSL} != "no"
2716+
.if ${.MAKE.OS} == "Darwin"
2717+
_bootstrap_libcrypto=secure/lib/libcrypto
2718+
${_bt}-usr.sbin/certctl: ${_bt}-secure/lib/libcrypto
2719+
.endif
27142720
_certctl=usr.sbin/certctl
27152721
.endif
27162722

@@ -2777,6 +2783,7 @@ bootstrap-tools: ${_bt}-links .PHONY
27772783
${_strfile} \
27782784
usr.bin/dtc \
27792785
${_cat} \
2786+
${_bootstrap_libcrypto} \
27802787
${_certctl} \
27812788
${_kbdcontrol} \
27822789
${_elftoolchain_libs} \

secure/lib/libcrypto/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
SHLIBDIR?= /lib
2-
.if !defined(LIBCRYPTO_WITHOUT_SUBDIRS)
2+
.if !defined(LIBCRYPTO_WITHOUT_SUBDIRS) && !defined(BOOTSTRAPPING)
33
SUBDIR= engines modules
44
.endif
5+
.ifdef BOOTSTRAPPING
6+
CFLAGS+= -DOPENSSL_NO_SCTP
7+
.endif
58

69
.include <bsd.own.mk>
710
.include <src.opts.mk>

secure/lib/libcrypto/Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CFLAGS+= -DL_ENDIAN
66
CFLAGS+= -DB_ENDIAN
77
.endif
88

9-
.ifndef WITHOUT_AUTO_ASM
9+
.if !defined(WITHOUT_AUTO_ASM) && !defined(BOOTSTRAPPING)
1010
.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
1111
${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "i386"
1212
ASM_${MACHINE_CPUARCH}=

share/mk/bsd.endian.mk

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@ LOCALEDEF_ENDIAN= -b
2020
#
2121
# During bootstrapping on !FreeBSD OSes, we need to define some value. Short of
2222
# having an exhaustive list for all variants of Linux and MacOS we simply do not
23-
# set TARGET_ENDIANNESS and poison the other variables. They should be unused
24-
# during the bootstrap phases (apart from one place that's adequately protected
25-
# in bsd.compiler.mk) where we're building the bootstrap tools.
23+
# set TARGET_ENDIANNESS (on Linux) and poison the other variables. They should
24+
# be unused during the bootstrap phases (apart from one place that's adequately
25+
# protected in bsd.compiler.mk) where we're building the bootstrap tools.
2626
#
27+
.if ${.MAKE.OS} == "Darwin"
28+
# We do assume the endianness on macOS because Apple's modern hardware is all
29+
# little-endian. This might need revisited in the far future, but for the time
30+
# being Apple Silicon's reign of terror continues. We only set this one up
31+
# because libcrypto is now built in bootstrap.
32+
TARGET_ENDIANNESS= 1234
33+
.endif
2734
CAP_MKDB_ENDIAN= -B # Poisoned value, invalid flags for both cap_mkdb
2835
LOCALEDEF_ENDIAN= -B # and localedef.
2936
.endif

tools/build/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ INSTALLDIR_LIST= \
495495
bin \
496496
lib/geom \
497497
usr/include/casper \
498+
usr/include/openssl \
498499
usr/include/private/ucl \
499500
usr/include/private/zstd \
500501
usr/lib \

0 commit comments

Comments
 (0)