$NetBSD: patch-SConstruct,v 1.12 2025/12/07 16:46:10 maya Exp $ Add support for NetBSD and Dragonfly. Avoid -fatal-warnings: ld might complain about conflicting versions. Fix locations. Don't compile with debug info. Don't mess with the linker. Respect LDFLAGS and CXXFLAGS. Fix bogus check for mongoc-1.0 library - we need call=somefunction(); otherwise it's part of the command line arguments to the compiler --- SConstruct.orig 2024-01-04 00:34:55.000000000 +0000 +++ SConstruct @@ -1259,6 +1259,7 @@ envDict = dict(BUILD_ROOT=buildDir, CONFIGURELOG='$BUILD_ROOT/scons/config.log', CONFIG_HEADER_DEFINES={}, LIBDEPS_TAG_EXPANSIONS=[], + ENV=os.environ, ) # By default, we will get the normal SCons tool search. But if the @@ -1448,7 +1449,9 @@ def CheckForProcessor(context, which_arc os_macros = { "windows": "defined(_WIN32)", "solaris": "defined(__sun)", + "dragonfly": "defined(__DragonFly__)", "freebsd": "defined(__FreeBSD__)", + "netbsd": "defined(__NetBSD__)", "openbsd": "defined(__OpenBSD__)", "iOS": "defined(__APPLE__) && TARGET_OS_IOS && !TARGET_OS_SIMULATOR", "iOS-sim": "defined(__APPLE__) && TARGET_OS_IOS && TARGET_OS_SIMULATOR", @@ -1584,7 +1587,7 @@ if env.TargetOSIs('posix'): env.Append( CCFLAGS_WERROR=["-Werror"], CXXFLAGS_WERROR=['-Werror=unused-result'] if env.ToolchainIs('clang') else [], - LINKFLAGS_WERROR=['-Wl,-fatal_warnings' if env.TargetOSIs('darwin') else "-Wl,--fatal-warnings"], + LINKFLAGS_WERROR=[''], ) elif env.TargetOSIs('windows'): env.Append( @@ -1999,7 +2002,7 @@ if env['_LIBDEPS'] == '$_LIBDEPS_LIBS': if not env.TargetOSIs('solaris', 'darwin', 'windows', 'openbsd'): env.Tool('thin_archive') -if env.TargetOSIs('linux', 'freebsd', 'openbsd'): +if env.TargetOSIs('linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly'): env['LINK_WHOLE_ARCHIVE_LIB_START'] = '-Wl,--whole-archive' env['LINK_WHOLE_ARCHIVE_LIB_END'] = '-Wl,--no-whole-archive' env['LINK_AS_NEEDED_LIB_START'] = '-Wl,--as-needed' @@ -2176,14 +2179,14 @@ if env.TargetOSIs('linux'): elif env.TargetOSIs('solaris'): env.Append( LIBS=["socket","resolv","lgrp"] ) -elif env.TargetOSIs('freebsd'): +elif env.TargetOSIs('freebsd', 'dragonfly'): env.Append( LIBS=[ "kvm" ] ) env.Append( CCFLAGS=[ "-fno-omit-frame-pointer" ] ) elif env.TargetOSIs('darwin'): env.Append( LIBS=["resolv"] ) -elif env.TargetOSIs('openbsd'): +elif env.TargetOSIs('netbsd', 'openbsd'): env.Append( LIBS=[ "kvm" ] ) elif env.TargetOSIs('windows'): @@ -2485,7 +2488,6 @@ if env.TargetOSIs('posix'): # -Winvalid-pch Warn if a precompiled header (see Precompiled Headers) is found in the search path but can't be used. env.Append( CCFLAGS=["-fasynchronous-unwind-tables", - "-ggdb" if not env.TargetOSIs('emscripten') else "-g", "-Wall", "-Wsign-compare", "-Wno-unknown-pragmas", @@ -3010,7 +3012,7 @@ def doConfigure(myenv): myenv.AddMethod( functools.partial(var_func, var=var, func=CheckFlag), f"Check{var}Supported") - if myenv.ToolchainIs('gcc', 'clang'): + if myenv.ToolchainIs('gcc', 'clang') and get_option('runtime-hardening') == "on": # This tells clang/gcc to use the gold linker if it is available - we prefer the gold linker # because it is much faster. Don't use it if the user has already configured another linker # selection manually. @@ -3406,9 +3408,6 @@ def doConfigure(myenv): if usingLibStdCxx: def CheckModernLibStdCxx(context): test_body = """ - #if !__has_include() - #error "libstdc++ from GCC 5.3.0 or newer is required" - #endif """ context.Message('Checking for libstdc++ 5.3.0 or better... ') @@ -3819,7 +3818,7 @@ def doConfigure(myenv): # Explicitly use the new gnu hash section if the linker offers # it, except on android since older runtimes seem to not # support it. For that platform, use 'both'. - if env.TargetOSIs('android'): + if env.TargetOSIs('android') or env.TargetOSIs('netbsd'): myenv.AddToLINKFLAGSIfSupported('-Wl,--hash-style=both') else: myenv.AddToLINKFLAGSIfSupported('-Wl,--hash-style=gnu') @@ -4110,8 +4109,9 @@ def doConfigure(myenv): def checkOpenSSL(conf): sslLibName = "ssl" cryptoLibName = "crypto" - sslLinkDependencies = ["crypto", "dl"] - if conf.env.TargetOSIs('freebsd'): + if conf.env.TargetOSIs('linux', 'solaris'): + sslLinkDependencies = ["crypto", "dl"] + else: sslLinkDependencies = ["crypto"] if conf.env.TargetOSIs('windows'): @@ -4448,7 +4448,7 @@ def doConfigure(myenv): myenv.ConfError("Couldn't find SASL header/libraries") # requires ports devel/libexecinfo to be installed - if env.TargetOSIs('freebsd', 'openbsd'): + if env.TargetOSIs('dragonfly', 'freebsd', 'netbsd', 'openbsd'): if not conf.CheckLib("execinfo"): myenv.ConfError("Cannot find libexecinfo, please install devel/libexecinfo.") @@ -4586,7 +4586,7 @@ def doConfigure(myenv): ["mongoc-1.0"], ["mongoc/mongoc.h"], "C", - "mongoc_get_major_version();", + call="mongoc_get_major_version();", autoadd=False ): conf.env['MONGO_HAVE_LIBMONGOC'] = True if not conf.env['MONGO_HAVE_LIBMONGOC'] and mongoc_mode == 'on':