Skip to content

Conversation

@zorbathut
Copy link
Contributor

This fixes LibGodot shared_library build to work properly on Linux; there was unfortunately some missing functionality in the original PR, #110863.

There's two fixes here:

  • The -fPIC flag needs to be introduced during the platform configure() step so that modules will be built with it.
  • The x11 and wayland platform sub-modules shouldn't use env.Object because it doesn't have the correct flags attached to it; instead they need to be added to linuxbsd/SCSub's common_linuxbsd array so that add_library, add_shared_library, or add_program can do the right thing. This basically just means that we need to return a path instead of an env.Object, but we do need to wrap it with a constant path to get the right complete filename. (There might be a cleaner way to do this.)

I can untangle these into separate PRs if you'd prefer them separate, this is just how I wrote 'em.

To test, run scons library_type=shared_library on Linux. (Shared libraries tend to be the pain point.)

@zorbathut zorbathut requested a review from a team as a code owner October 8, 2025 22:17
@zorbathut zorbathut force-pushed the pr/libgodot_linux_fix branch from de2bd50 to b453f28 Compare October 8, 2025 22:25
@zorbathut zorbathut force-pushed the pr/libgodot_linux_fix branch from b453f28 to d3fca68 Compare October 8, 2025 22:38
@zorbathut zorbathut requested review from a team as code owners October 8, 2025 22:38
@zorbathut zorbathut force-pushed the pr/libgodot_linux_fix branch from d3fca68 to 111fa6e Compare October 8, 2025 22:38
@zorbathut
Copy link
Contributor Author

Should be ready now, apologies for my minor tiff with Git.

Copy link
Contributor

@deralmas deralmas left a comment

Choose a reason for hiding this comment

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

There might be a cleaner way to do this.

I'm no build system expert, but I suppose that we could at least iterate over source_files and append base in a loop instead of doing it every time?

@zorbathut
Copy link
Contributor Author

I'm no build system expert, but I suppose that we could at least iterate over source_files and append base in a loop instead of doing it every time?

It's a little more complicated than this because x11 includes a file that actually has an absolute path ("#thirdparty/glad/glx.c") so there needs to be a little logic to avoid that one, or it needs to be appended afterwards, which itself is complicated because it's only added in a conditional. I'll give it a shot though.

@deralmas
Copy link
Contributor

deralmas commented Oct 9, 2025

It's a little more complicated than this because x11 includes a file that actually has an absolute path ("#thirdparty/glad/glx.c")

Ooooh aight that's fair then. Nw if accounting for it is a mess, it's fine if we append base manually too.

@deralmas
Copy link
Contributor

deralmas commented Oct 9, 2025

Hi, I've taken a look at the SCons docs and it looks like we might also use a File node. From what I can tell, it resolves the path on initialization and then can be used anywhere, so that we don't have to hardcode the platform's path.

File Nodes can be used anywhere you would supply a string as a file name to a Builder method or function.

Seems quite handy, let me know if that does the job :D

@zorbathut
Copy link
Contributor Author

zorbathut commented Oct 9, 2025

Alright, tried them all :V Github appears to be having technical issues right now so they're not showing up on this page, but here's direct links:

Manual base-prepend

Postprocess base-prepend

Manual Path

I didn't do a "postprocess Path", I could do that too.

They're all a little ugly in slightly different ways. I have no strong feelings here. Is there a person I should ping on the build team to figure out which they prefer? Happy to do whatever.

@zorbathut zorbathut force-pushed the pr/libgodot_linux_fix branch 3 times, most recently from 20e8434 to 1c415dc Compare October 9, 2025 16:17
@fire
Copy link
Member

fire commented Oct 9, 2025

Personally I use list each path as a string so things aren't too abstracted, but I'd go with the reviewer commentary.

From my point of view I only start looking into optimizations when I have lists of 100s of filepaths.

@deralmas
Copy link
Contributor

deralmas commented Oct 9, 2025

From my point of view I only start looking into optimizations when I have lists of 100s of filepaths.

This isn't really much of an optimization, more like avoiding to hardcode paths into platforms dirs. While that shouldn't matter, it's still good practice, as platform implementations are supposed to be reasonably self-contained from the rest of the engine.

@zorbathut
Copy link
Contributor Author

Yeah, I'm zero-percent concerned about performance here, and one-hundred-percent concerned about code cleanliness. I'm just not sure which of these is the cleanest.

@deralmas
Copy link
Contributor

deralmas commented Oct 9, 2025

Personally I find this File thing pretty clean, and good code hygiene in general, since you're making it explicit that you're referring to a file :)

That said I don't really specialize in maintaining the build system so TIWAGOS.

The build team already got pinged around thanks to CODEOWNERS but it's also true that most of it is like, perennially busy.

File("gl_manager_x11_egl.cpp"),
File("gl_manager_x11.cpp"),
File("detect_prime_x11.cpp"),
"#thirdparty/glad/glx.c",
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW I Think that it should work for top-relative path names too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, I'll put that in for the sake of consistency.

Copy link
Contributor

@deralmas deralmas left a comment

Choose a reason for hiding this comment

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

Personally, I think that this looks great :D

@zorbathut zorbathut force-pushed the pr/libgodot_linux_fix branch from d66cd80 to 3e00682 Compare October 10, 2025 09:30
@zorbathut zorbathut force-pushed the pr/libgodot_linux_fix branch from 3e00682 to 0a58425 Compare October 10, 2025 09:31
@zorbathut
Copy link
Contributor Author

Just gonna squash down to that one then, I think it's probably the best of the batch.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Seems fine.

Copy link
Contributor

@Repiteo Repiteo left a comment

Choose a reason for hiding this comment

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

The X11/Wayland SCsub files are definitely unconventional here, but that was apparently already the case, so I won't consider it a blocker. Will absolutely give them a pass in a followup PR though

@Repiteo Repiteo merged commit cf9e2ea into godotengine:master Oct 10, 2025
20 checks passed
@zorbathut zorbathut deleted the pr/libgodot_linux_fix branch October 10, 2025 15:38
@Repiteo
Copy link
Contributor

Repiteo commented Oct 10, 2025

Thanks!

svenpaulsen pushed a commit to svenpaulsen/godot that referenced this pull request Nov 27, 2025
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.

7 participants