Skip to content

Fix builds on FreeBSD, OpenBSD, and NetBSD#114233

Open
Kaleb-Reid wants to merge 1 commit intogodotengine:masterfrom
Kaleb-Reid:fix-openbsd
Open

Fix builds on FreeBSD, OpenBSD, and NetBSD#114233
Kaleb-Reid wants to merge 1 commit intogodotengine:masterfrom
Kaleb-Reid:fix-openbsd

Conversation

@Kaleb-Reid
Copy link
Copy Markdown
Contributor

@Kaleb-Reid Kaleb-Reid commented Dec 20, 2025

I was able to compile from scratch on FreeBSD 15.0 / 13.5, OpenBSD 7.8 / 7.7, and NetBSD 10.1 without disabling anything using this pr.

I briefly ran the editor on OpenBSD, created a new project, and add a couple nodes in 3D. I currently do not have access to a FreeBSD or NetBSD machine with a display out so I have only briefly tested them in headless mode.

Basically what I've done when compiling under bsd:

  • Use bsd joystick implementation in sdl.
  • Disabled haptics.
  • Disabled camera module.
  • Dont set HAVE_SECURE_GETENV for openxr.
  • Modify linker flags and fix clang / gcc detection.
  • Directly define mouse button codes so that input-event-codes.h can be removed because it is not available on NetBSD.
  • Replace a few system apis with their bsd counterparts.
  • Fix some warnings which become errors when compiling in dev mode.
  • Replace some problem instances of size_t with uint64_t in the wayland implementation instead of adding a long constructor to Variant due to OpenBSD defining size_t as long. The two wayland files are the only ones in the project with this problem so it seems overkill to change Variant to fix the problem.

Also the issue in #101588 (comment) where the editor would not compile is due to the process memory limit being relatively low in OpenBSD by default (1.5GB for users with the staff class). I also had this failure around the same part, but if you raise the limit (e.g. ulimit -d 10000000), then you can compile fine.

Fixes #55192
Fixes #92130
Fixes #110606
Supersedes #101588

@Kaleb-Reid Kaleb-Reid requested review from a team as code owners December 20, 2025 10:45
@Kaleb-Reid Kaleb-Reid force-pushed the fix-openbsd branch 2 times, most recently from 7ea07f8 to c36d3f7 Compare December 20, 2025 11:50
@akien-mga akien-mga added this to the 4.x milestone Dec 20, 2025
Comment thread thirdparty/sdl/patches/0007-fix-openbsd.patch Outdated
@Kaleb-Reid Kaleb-Reid force-pushed the fix-openbsd branch 3 times, most recently from caeded2 to 59b9ca1 Compare December 21, 2025 00:50
@Kaleb-Reid Kaleb-Reid changed the title Fix compiling on OpenBSD Fix compiling on OpenBSD and FreeBSD Dec 21, 2025
@Kaleb-Reid Kaleb-Reid force-pushed the fix-openbsd branch 3 times, most recently from 92cbbcd to fb38fe1 Compare December 22, 2025 01:37
@Kaleb-Reid Kaleb-Reid requested a review from a team as a code owner December 22, 2025 01:37
@Kaleb-Reid Kaleb-Reid changed the title Fix compiling on OpenBSD and FreeBSD Fix building on FreeBSD, OpenBSD, and NetBSD Dec 22, 2025
@Kaleb-Reid Kaleb-Reid changed the title Fix building on FreeBSD, OpenBSD, and NetBSD Fix builds on FreeBSD, OpenBSD, and NetBSD Dec 22, 2025
@Kaleb-Reid Kaleb-Reid force-pushed the fix-openbsd branch 6 times, most recently from 830e724 to 65af78a Compare December 24, 2025 04:17
@Kaleb-Reid
Copy link
Copy Markdown
Contributor Author

I'm moving the changes to the wrappers to a new pr, this pr still fixes compilation but optional runtime libraries will not be found on OpenBSD or NetBSD.

@Kaleb-Reid
Copy link
Copy Markdown
Contributor Author

@DeanLemans I'm essentially just waiting for reviews.

@Kaleb-Reid Kaleb-Reid force-pushed the fix-openbsd branch 2 times, most recently from abda78e to d04ff90 Compare April 20, 2026 00:57
Comment thread thirdparty/linuxbsd_headers/input-event-codes/input-event-codes.h Outdated
Comment thread drivers/sdl/SDL_build_config_private.h
Comment thread modules/camera/config.py Outdated
Comment thread platform/linuxbsd/wayland/wayland_embedder.cpp
Comment thread platform/linuxbsd/detect.py Outdated
Comment thread platform/linuxbsd/detect.py Outdated
Comment thread platform/linuxbsd/detect.py Outdated
Comment thread platform/linuxbsd/detect.py Outdated
Comment thread platform/linuxbsd/platform_config.h Outdated
Comment thread thirdparty/sdl/hidapi/netbsd/hid.c
Comment thread drivers/sdl/SCsub
@Kaleb-Reid Kaleb-Reid force-pushed the fix-openbsd branch 6 times, most recently from bd8906b to 2677f9a Compare April 24, 2026 07:56
@Kaleb-Reid Kaleb-Reid requested a review from a team as a code owner April 24, 2026 07:56
@Kaleb-Reid Kaleb-Reid force-pushed the fix-openbsd branch 3 times, most recently from 67e0b1e to 06745cc Compare April 26, 2026 21:08
@Kaleb-Reid Kaleb-Reid requested a review from akien-mga April 26, 2026 22:05
Comment thread drivers/unix/os_unix.cpp
int count = swapctl(SWAP_NSWAP, 0, 0);
if (count > 0) {
swapent swap_info[count];
swapent *swap_info = (swapent *)memalloc(count * sizeof(swapent));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @bruvzg to review this bit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems fine, but not sure why having it on stack was an issue, was it too large because of PATH_MAX?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bruvzg This triggered a compiler warning for having a variable length array, which in dev mode aborted compilation.

Comment thread platform/linuxbsd/detect.py
Comment on lines +627 to +631
////////////////////////////////////////////////////////////////////////////////
/// OpenBSD Platform
////////////////////////////////////////////////////////////////////////////////

#if defined (__OPENBSD__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you look into contributing this upstream to Embree?

Copy link
Copy Markdown
Contributor Author

@Kaleb-Reid Kaleb-Reid Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akien-mga I didn't bother to because the OpenBSD implementations of the functions are just dummy implementations. Until now so were the NetBSD ones, but I just changed them to be the same as the Linux implementations as NetBSD seems to support the same interfaces as Linux in this case.

Comment thread methods.py Outdated
Comment on lines +811 to +820
return "gcc" in os.path.basename(env["CC"]) or (
sys.platform.startswith("netbsd") and os.path.basename(env["CC"] == "cc")
)


def using_clang(env):
return "clang" in os.path.basename(env["CC"])
return "clang" in os.path.basename(env["CC"]) or (
(sys.platform.startswith("freebsd") or sys.platform.startswith("openbsd"))
and os.path.basename(env["CC"]) == "cc"
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds quite error prone if either of these *BSD platforms change their default cc compiler in the future. They don't provide gcc and clang binaries?

It's been working in the past without requiring those changes, I wonder why this is needed now.

Copy link
Copy Markdown
Contributor Author

@Kaleb-Reid Kaleb-Reid Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akien-mga I may be able to revert the NetBSD one, but the other two are necessary because it was causing builds done with the default system compiler (cc which is a copy of clang) to not be forced as llvm builds which made certain compiler flags not be applied, causing issues such as failing when compiling in dev mode due to missing flags to ignore warnings as well as not adding the clang-specific linker flags for statically linking libc++. If instead we check CXX, I believe only OpenBSD would need a workaround because it's default is c++ which is a copy of clang++.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted the modification to using_gcc but kept the one to using_clang

Comment thread methods.py Outdated
@pescador-barquero
Copy link
Copy Markdown

I just noticed there's a FreeBSD ports update for 4.6.1. Sharing here just in case you haven't seen it.
https://www.freshports.org/devel/godot

@Kaleb-Reid Kaleb-Reid requested a review from akien-mga May 3, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Godot 4.5 FreeBSD build failure - depends on linuxisms OpenBSD build is broken due to compilation errors Embree fails building on OpenBSD 7.0

7 participants