detect.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. import os
  2. import platform
  3. import sys
  4. from typing import TYPE_CHECKING
  5. from methods import get_compiler_version, print_error, print_info, print_warning, using_gcc
  6. from platform_methods import detect_arch, validate_arch
  7. if TYPE_CHECKING:
  8. from SCons.Script.SConscript import SConsEnvironment
  9. def get_name():
  10. return "LinuxBSD"
  11. def can_build():
  12. if os.name != "posix" or sys.platform == "darwin":
  13. return False
  14. pkgconf_error = os.system("pkg-config --version > /dev/null")
  15. if pkgconf_error:
  16. print_error("pkg-config not found. Aborting.")
  17. return False
  18. return True
  19. def get_opts():
  20. from SCons.Variables import BoolVariable, EnumVariable
  21. return [
  22. EnumVariable("linker", "Linker program", "default", ("default", "bfd", "gold", "lld", "mold")),
  23. BoolVariable("use_llvm", "Use the LLVM compiler", False),
  24. BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", True),
  25. BoolVariable("use_coverage", "Test Godot coverage", False),
  26. BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False),
  27. BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN)", False),
  28. BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN)", False),
  29. BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN)", False),
  30. BoolVariable("use_msan", "Use LLVM compiler memory sanitizer (MSAN)", False),
  31. BoolVariable("use_sowrap", "Dynamically load system libraries", True),
  32. BoolVariable("alsa", "Use ALSA", True),
  33. BoolVariable("pulseaudio", "Use PulseAudio", True),
  34. BoolVariable("dbus", "Use D-Bus to handle screensaver and portal desktop settings", True),
  35. BoolVariable("speechd", "Use Speech Dispatcher for Text-to-Speech support", True),
  36. BoolVariable("fontconfig", "Use fontconfig for system fonts support", True),
  37. BoolVariable("udev", "Use udev for gamepad connection callbacks", True),
  38. BoolVariable("x11", "Enable X11 display", True),
  39. BoolVariable("wayland", "Enable Wayland display", True),
  40. BoolVariable("libdecor", "Enable libdecor support", True),
  41. BoolVariable("touch", "Enable touch events", True),
  42. BoolVariable("execinfo", "Use libexecinfo on systems where glibc is not available", False),
  43. ]
  44. def get_doc_classes():
  45. return [
  46. "EditorExportPlatformLinuxBSD",
  47. ]
  48. def get_doc_path():
  49. return "doc_classes"
  50. def get_flags():
  51. return {
  52. "arch": detect_arch(),
  53. "supported": ["mono"],
  54. }
  55. def configure(env: "SConsEnvironment"):
  56. # Validate arch.
  57. supported_arches = ["x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc32", "ppc64", "loongarch64"]
  58. validate_arch(env["arch"], get_name(), supported_arches)
  59. ## Build type
  60. if env.dev_build:
  61. # This is needed for our crash handler to work properly.
  62. # gdb works fine without it though, so maybe our crash handler could too.
  63. env.Append(LINKFLAGS=["-rdynamic"])
  64. # Cross-compilation
  65. # TODO: Support cross-compilation on architectures other than x86.
  66. host_is_64_bit = sys.maxsize > 2**32
  67. if host_is_64_bit and env["arch"] == "x86_32":
  68. env.Append(CCFLAGS=["-m32"])
  69. env.Append(LINKFLAGS=["-m32"])
  70. elif not host_is_64_bit and env["arch"] == "x86_64":
  71. env.Append(CCFLAGS=["-m64"])
  72. env.Append(LINKFLAGS=["-m64"])
  73. # CPU architecture flags.
  74. if env["arch"] == "rv64":
  75. # G = General-purpose extensions, C = Compression extension (very common).
  76. env.Append(CCFLAGS=["-march=rv64gc"])
  77. ## Compiler configuration
  78. if "CXX" in env and "clang" in os.path.basename(env["CXX"]):
  79. # Convenience check to enforce the use_llvm overrides when CXX is clang(++)
  80. env["use_llvm"] = True
  81. if env["use_llvm"]:
  82. if "clang++" not in os.path.basename(env["CXX"]):
  83. env["CC"] = "clang"
  84. env["CXX"] = "clang++"
  85. env.extra_suffix = ".llvm" + env.extra_suffix
  86. if env["linker"] != "default":
  87. print("Using linker program: " + env["linker"])
  88. if env["linker"] == "mold" and using_gcc(env): # GCC < 12.1 doesn't support -fuse-ld=mold.
  89. cc_version = get_compiler_version(env)
  90. cc_semver = (cc_version["major"], cc_version["minor"])
  91. if cc_semver < (12, 1):
  92. found_wrapper = False
  93. for path in ["/usr/libexec", "/usr/local/libexec", "/usr/lib", "/usr/local/lib"]:
  94. if os.path.isfile(path + "/mold/ld"):
  95. env.Append(LINKFLAGS=["-B" + path + "/mold"])
  96. found_wrapper = True
  97. break
  98. if not found_wrapper:
  99. for path in os.environ["PATH"].split(os.pathsep):
  100. if os.path.isfile(path + "/ld.mold"):
  101. env.Append(LINKFLAGS=["-B" + path])
  102. found_wrapper = True
  103. break
  104. if not found_wrapper:
  105. print_error(
  106. "Couldn't locate mold installation path. Make sure it's installed in /usr, /usr/local or in PATH environment variable."
  107. )
  108. sys.exit(255)
  109. else:
  110. env.Append(LINKFLAGS=["-fuse-ld=mold"])
  111. else:
  112. env.Append(LINKFLAGS=["-fuse-ld=%s" % env["linker"]])
  113. if env["use_coverage"]:
  114. env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"])
  115. env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"])
  116. if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"] or env["use_msan"]:
  117. env.extra_suffix += ".san"
  118. env.Append(CCFLAGS=["-DSANITIZERS_ENABLED"])
  119. if env["use_ubsan"]:
  120. env.Append(
  121. CCFLAGS=[
  122. "-fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin"
  123. ]
  124. )
  125. env.Append(LINKFLAGS=["-fsanitize=undefined"])
  126. if env["use_llvm"]:
  127. env.Append(
  128. CCFLAGS=[
  129. "-fsanitize=nullability-return,nullability-arg,function,nullability-assign,implicit-integer-sign-change"
  130. ]
  131. )
  132. else:
  133. env.Append(CCFLAGS=["-fsanitize=bounds-strict"])
  134. if env["use_asan"]:
  135. env.Append(CCFLAGS=["-fsanitize=address,pointer-subtract,pointer-compare"])
  136. env.Append(LINKFLAGS=["-fsanitize=address"])
  137. if env["use_lsan"]:
  138. env.Append(CCFLAGS=["-fsanitize=leak"])
  139. env.Append(LINKFLAGS=["-fsanitize=leak"])
  140. if env["use_tsan"]:
  141. env.Append(CCFLAGS=["-fsanitize=thread"])
  142. env.Append(LINKFLAGS=["-fsanitize=thread"])
  143. if env["use_msan"] and env["use_llvm"]:
  144. env.Append(CCFLAGS=["-fsanitize=memory"])
  145. env.Append(CCFLAGS=["-fsanitize-memory-track-origins"])
  146. env.Append(CCFLAGS=["-fsanitize-recover=memory"])
  147. env.Append(LINKFLAGS=["-fsanitize=memory"])
  148. env.Append(CCFLAGS=["-ffp-contract=off"])
  149. # LTO
  150. if env["lto"] == "auto": # Enable LTO for production.
  151. env["lto"] = "thin" if env["use_llvm"] else "full"
  152. if env["lto"] != "none":
  153. if env["lto"] == "thin":
  154. if not env["use_llvm"]:
  155. print_error("ThinLTO is only compatible with LLVM, use `use_llvm=yes` or `lto=full`.")
  156. sys.exit(255)
  157. env.Append(CCFLAGS=["-flto=thin"])
  158. env.Append(LINKFLAGS=["-flto=thin"])
  159. elif not env["use_llvm"] and env.GetOption("num_jobs") > 1:
  160. env.Append(CCFLAGS=["-flto"])
  161. env.Append(LINKFLAGS=["-flto=" + str(env.GetOption("num_jobs"))])
  162. else:
  163. env.Append(CCFLAGS=["-flto"])
  164. env.Append(LINKFLAGS=["-flto"])
  165. if not env["use_llvm"]:
  166. env["RANLIB"] = "gcc-ranlib"
  167. env["AR"] = "gcc-ar"
  168. env.Append(CCFLAGS=["-pipe"])
  169. ## Dependencies
  170. if env["use_sowrap"]:
  171. env.Append(CPPDEFINES=["SOWRAP_ENABLED"])
  172. if env["wayland"]:
  173. if os.system("wayland-scanner -v 2>/dev/null") != 0:
  174. print_warning("wayland-scanner not found. Disabling Wayland support.")
  175. env["wayland"] = False
  176. if env["touch"]:
  177. env.Append(CPPDEFINES=["TOUCH_ENABLED"])
  178. # FIXME: Check for existence of the libs before parsing their flags with pkg-config
  179. if not env["builtin_freetype"]:
  180. env.ParseConfig("pkg-config freetype2 --cflags --libs")
  181. if not env["builtin_graphite"]:
  182. env.ParseConfig("pkg-config graphite2 --cflags --libs")
  183. if not env["builtin_icu4c"]:
  184. env.ParseConfig("pkg-config icu-i18n icu-uc --cflags --libs")
  185. if not env["builtin_harfbuzz"]:
  186. env.ParseConfig("pkg-config harfbuzz harfbuzz-icu --cflags --libs")
  187. if not env["builtin_icu4c"] or not env["builtin_harfbuzz"]:
  188. print_warning(
  189. "System-provided icu4c or harfbuzz cause known issues for GDExtension (see GH-91401 and GH-100301)."
  190. )
  191. if not env["builtin_libpng"]:
  192. env.ParseConfig("pkg-config libpng16 --cflags --libs")
  193. if not env["builtin_enet"]:
  194. env.ParseConfig("pkg-config libenet --cflags --libs")
  195. if not env["builtin_zstd"]:
  196. env.ParseConfig("pkg-config libzstd --cflags --libs")
  197. if env["brotli"] and not env["builtin_brotli"]:
  198. env.ParseConfig("pkg-config libbrotlicommon libbrotlidec --cflags --libs")
  199. # Sound and video libraries
  200. # Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
  201. if not env["builtin_libtheora"]:
  202. env["builtin_libogg"] = False # Needed to link against system libtheora
  203. env["builtin_libvorbis"] = False # Needed to link against system libtheora
  204. env.ParseConfig("pkg-config theora theoradec --cflags --libs")
  205. else:
  206. if env["arch"] in ["x86_64", "x86_32"]:
  207. env["x86_libtheora_opt_gcc"] = True
  208. if not env["builtin_libvorbis"]:
  209. env["builtin_libogg"] = False # Needed to link against system libvorbis
  210. env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs")
  211. if not env["builtin_libogg"]:
  212. env.ParseConfig("pkg-config ogg --cflags --libs")
  213. if not env["builtin_libwebp"]:
  214. env.ParseConfig("pkg-config libwebp --cflags --libs")
  215. if not env["builtin_mbedtls"]:
  216. # mbedTLS only provides a pkgconfig file since 3.6.0, but we still support 2.28.x,
  217. # so fallback to manually specifying LIBS if it fails.
  218. if os.system("pkg-config --exists mbedtls") == 0: # 0 means found
  219. env.ParseConfig("pkg-config mbedtls mbedcrypto mbedx509 --cflags --libs")
  220. else:
  221. env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
  222. if not env["builtin_wslay"]:
  223. env.ParseConfig("pkg-config libwslay --cflags --libs")
  224. if not env["builtin_miniupnpc"]:
  225. env.ParseConfig("pkg-config miniupnpc --cflags --libs")
  226. # On Linux wchar_t should be 32-bits
  227. # 16-bit library shouldn't be required due to compiler optimizations
  228. if not env["builtin_pcre2"]:
  229. env.ParseConfig("pkg-config libpcre2-32 --cflags --libs")
  230. if not env["builtin_recastnavigation"]:
  231. # No pkgconfig file so far, hardcode default paths.
  232. env.Prepend(CPPEXTPATH=["/usr/include/recastnavigation"])
  233. env.Append(LIBS=["Recast"])
  234. if not env["builtin_embree"] and env["arch"] in ["x86_64", "arm64"]:
  235. # No pkgconfig file so far, hardcode expected lib name.
  236. env.Append(LIBS=["embree4"])
  237. if not env["builtin_openxr"]:
  238. env.ParseConfig("pkg-config openxr --cflags --libs")
  239. if env["fontconfig"]:
  240. if not env["use_sowrap"]:
  241. if os.system("pkg-config --exists fontconfig") == 0: # 0 means found
  242. env.ParseConfig("pkg-config fontconfig --cflags --libs")
  243. env.Append(CPPDEFINES=["FONTCONFIG_ENABLED"])
  244. else:
  245. print_warning("fontconfig development libraries not found. Disabling the system fonts support.")
  246. env["fontconfig"] = False
  247. else:
  248. env.Append(CPPDEFINES=["FONTCONFIG_ENABLED"])
  249. if env["alsa"]:
  250. if not env["use_sowrap"]:
  251. if os.system("pkg-config --exists alsa") == 0: # 0 means found
  252. env.ParseConfig("pkg-config alsa --cflags --libs")
  253. env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"])
  254. else:
  255. print_warning("ALSA development libraries not found. Disabling the ALSA audio driver.")
  256. env["alsa"] = False
  257. else:
  258. env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"])
  259. if env["pulseaudio"]:
  260. if not env["use_sowrap"]:
  261. if os.system("pkg-config --exists libpulse") == 0: # 0 means found
  262. env.ParseConfig("pkg-config libpulse --cflags --libs")
  263. env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED"])
  264. else:
  265. print_warning("PulseAudio development libraries not found. Disabling the PulseAudio audio driver.")
  266. env["pulseaudio"] = False
  267. else:
  268. env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED", "_REENTRANT"])
  269. if env["dbus"]:
  270. if not env["use_sowrap"]:
  271. if os.system("pkg-config --exists dbus-1") == 0: # 0 means found
  272. env.ParseConfig("pkg-config dbus-1 --cflags --libs")
  273. env.Append(CPPDEFINES=["DBUS_ENABLED"])
  274. else:
  275. print_warning("D-Bus development libraries not found. Disabling screensaver prevention.")
  276. env["dbus"] = False
  277. else:
  278. env.Append(CPPDEFINES=["DBUS_ENABLED"])
  279. if env["speechd"]:
  280. if not env["use_sowrap"]:
  281. if os.system("pkg-config --exists speech-dispatcher") == 0: # 0 means found
  282. env.ParseConfig("pkg-config speech-dispatcher --cflags --libs")
  283. env.Append(CPPDEFINES=["SPEECHD_ENABLED"])
  284. else:
  285. print_warning("speech-dispatcher development libraries not found. Disabling text to speech support.")
  286. env["speechd"] = False
  287. else:
  288. env.Append(CPPDEFINES=["SPEECHD_ENABLED"])
  289. if not env["use_sowrap"]:
  290. if os.system("pkg-config --exists xkbcommon") == 0: # 0 means found
  291. env.ParseConfig("pkg-config xkbcommon --cflags --libs")
  292. env.Append(CPPDEFINES=["XKB_ENABLED"])
  293. else:
  294. if env["wayland"]:
  295. print_error("libxkbcommon development libraries required by Wayland not found. Aborting.")
  296. sys.exit(255)
  297. else:
  298. print_warning(
  299. "libxkbcommon development libraries not found. Disabling dead key composition and key label support."
  300. )
  301. else:
  302. env.Append(CPPDEFINES=["XKB_ENABLED"])
  303. if platform.system() == "Linux":
  304. env.Append(CPPDEFINES=["JOYDEV_ENABLED"])
  305. if env["udev"]:
  306. if not env["use_sowrap"]:
  307. if os.system("pkg-config --exists libudev") == 0: # 0 means found
  308. env.ParseConfig("pkg-config libudev --cflags --libs")
  309. env.Append(CPPDEFINES=["UDEV_ENABLED"])
  310. else:
  311. print_warning("libudev development libraries not found. Disabling controller hotplugging support.")
  312. env["udev"] = False
  313. else:
  314. env.Append(CPPDEFINES=["UDEV_ENABLED"])
  315. else:
  316. env["udev"] = False # Linux specific
  317. # Linkflags below this line should typically stay the last ones
  318. if not env["builtin_zlib"]:
  319. env.ParseConfig("pkg-config zlib --cflags --libs")
  320. env.Prepend(CPPPATH=["#platform/linuxbsd"])
  321. if env["use_sowrap"]:
  322. env.Prepend(CPPEXTPATH=["#thirdparty/linuxbsd_headers"])
  323. env.Append(
  324. CPPDEFINES=[
  325. "LINUXBSD_ENABLED",
  326. "UNIX_ENABLED",
  327. ("_FILE_OFFSET_BITS", 64),
  328. ]
  329. )
  330. if env["x11"]:
  331. if not env["use_sowrap"]:
  332. if os.system("pkg-config --exists x11"):
  333. print_error("X11 libraries not found. Aborting.")
  334. sys.exit(255)
  335. env.ParseConfig("pkg-config x11 --cflags --libs")
  336. if os.system("pkg-config --exists xcursor"):
  337. print_error("Xcursor library not found. Aborting.")
  338. sys.exit(255)
  339. env.ParseConfig("pkg-config xcursor --cflags --libs")
  340. if os.system("pkg-config --exists xinerama"):
  341. print_error("Xinerama library not found. Aborting.")
  342. sys.exit(255)
  343. env.ParseConfig("pkg-config xinerama --cflags --libs")
  344. if os.system("pkg-config --exists xext"):
  345. print_error("Xext library not found. Aborting.")
  346. sys.exit(255)
  347. env.ParseConfig("pkg-config xext --cflags --libs")
  348. if os.system("pkg-config --exists xrandr"):
  349. print_error("XrandR library not found. Aborting.")
  350. sys.exit(255)
  351. env.ParseConfig("pkg-config xrandr --cflags --libs")
  352. if os.system("pkg-config --exists xrender"):
  353. print_error("XRender library not found. Aborting.")
  354. sys.exit(255)
  355. env.ParseConfig("pkg-config xrender --cflags --libs")
  356. if os.system("pkg-config --exists xi"):
  357. print_error("Xi library not found. Aborting.")
  358. sys.exit(255)
  359. env.ParseConfig("pkg-config xi --cflags --libs")
  360. env.Append(CPPDEFINES=["X11_ENABLED"])
  361. if env["wayland"]:
  362. if not env["use_sowrap"]:
  363. if os.system("pkg-config --exists libdecor-0"):
  364. print_warning("libdecor development libraries not found. Disabling client-side decorations.")
  365. env["libdecor"] = False
  366. else:
  367. env.ParseConfig("pkg-config libdecor-0 --cflags --libs")
  368. if os.system("pkg-config --exists wayland-client"):
  369. print_error("Wayland client library not found. Aborting.")
  370. sys.exit(255)
  371. env.ParseConfig("pkg-config wayland-client --cflags --libs")
  372. if os.system("pkg-config --exists wayland-cursor"):
  373. print_error("Wayland cursor library not found. Aborting.")
  374. sys.exit(255)
  375. env.ParseConfig("pkg-config wayland-cursor --cflags --libs")
  376. if os.system("pkg-config --exists wayland-egl"):
  377. print_error("Wayland EGL library not found. Aborting.")
  378. sys.exit(255)
  379. env.ParseConfig("pkg-config wayland-egl --cflags --libs")
  380. else:
  381. env.Prepend(CPPEXTPATH=["#thirdparty/linuxbsd_headers/wayland/"])
  382. if env["libdecor"]:
  383. env.Prepend(CPPEXTPATH=["#thirdparty/linuxbsd_headers/libdecor-0/"])
  384. if env["libdecor"]:
  385. env.Append(CPPDEFINES=["LIBDECOR_ENABLED"])
  386. env.Append(CPPDEFINES=["WAYLAND_ENABLED"])
  387. env.Append(LIBS=["rt"]) # Needed by glibc, used by _allocate_shm_file
  388. if env["accesskit"]:
  389. if env["accesskit_sdk_path"] != "":
  390. env.Prepend(CPPPATH=[env["accesskit_sdk_path"] + "/include"])
  391. if env["arch"] == "arm64":
  392. env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/arm64/static/"])
  393. elif env["arch"] == "arm32":
  394. env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/arm32/static/"])
  395. elif env["arch"] == "rv64":
  396. env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/riscv64gc/static/"])
  397. elif env["arch"] == "x86_64":
  398. env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/x86_64/static/"])
  399. elif env["arch"] == "x86_32":
  400. env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/x86/static/"])
  401. env.Append(LIBS=["accesskit"])
  402. else:
  403. env.Append(CPPDEFINES=["ACCESSKIT_DYNAMIC"])
  404. env.Append(CPPDEFINES=["ACCESSKIT_ENABLED"])
  405. if env["vulkan"]:
  406. env.Append(CPPDEFINES=["VULKAN_ENABLED", "RD_ENABLED"])
  407. if not env["use_volk"]:
  408. env.ParseConfig("pkg-config vulkan --cflags --libs")
  409. if not env["builtin_glslang"]:
  410. # No pkgconfig file so far, hardcode expected lib name.
  411. env.Append(LIBS=["glslang", "SPIRV"])
  412. if env["opengl3"]:
  413. env.Append(CPPDEFINES=["GLES3_ENABLED"])
  414. env.Append(LIBS=["pthread"])
  415. if platform.system() == "Linux":
  416. env.Append(LIBS=["dl"])
  417. if platform.libc_ver()[0] != "glibc":
  418. if env["execinfo"]:
  419. env.Append(LIBS=["execinfo"])
  420. env.Append(CPPDEFINES=["CRASH_HANDLER_ENABLED"])
  421. else:
  422. # The default crash handler depends on glibc, so if the host uses
  423. # a different libc (BSD libc, musl), libexecinfo is required.
  424. print_info("Using `execinfo=no` disables the crash handler on platforms where glibc is missing.")
  425. else:
  426. env.Append(CPPDEFINES=["CRASH_HANDLER_ENABLED"])
  427. if platform.system() == "FreeBSD":
  428. env.Append(LINKFLAGS=["-lkvm"])
  429. # Link those statically for portability
  430. if env["use_static_cpp"]:
  431. env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
  432. if env["use_llvm"] and platform.system() != "FreeBSD":
  433. env["LINKCOM"] = env["LINKCOM"] + " -l:libatomic.a"
  434. else:
  435. if env["use_llvm"] and platform.system() != "FreeBSD":
  436. env.Append(LIBS=["atomic"])