Skip to content

build: turn on engine warnings and hide non-exported symbols on linux - #199

Open
CanReader wants to merge 3 commits into
mainfrom
build/warnings-visibility
Open

CanReader wants to merge 3 commits into
mainfrom
build/warnings-visibility

Conversation

@CanReader

@CanReader CanReader commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Two things on the Engine target, stacked on #194.

Warnings: engine sources now build with -Wall -Wextra -Wpedantic on GCC/Clang and /W4 on MSVC. No -Werror. They are set per source on the engine's own .cpp files, so the imgui sources, glad.c and stb_image_impl.cpp that get compiled into the target are left alone. The vendor subdirectories are added with SYSTEM and the vendor include dirs (spdlog, json, imgui, glad, stb, Vulkan) moved to a SYSTEM block, so warnings from their headers do not show up in engine TUs either.

Visibility: CXX_VISIBILITY_PRESET hidden, C_VISIBILITY_PRESET hidden and VISIBILITY_INLINES_HIDDEN on the target, and ENGINE_API in Core/OSDef.hpp is now __attribute__((visibility("default"))) everywhere that is not Windows (one define after the platform chain instead of the three empty ones). Then ENGINE_API on what was missing it:

  • classes: PhysicsWorld, DynamicAABBTree, Timer, File, Quaternion, Color, Serializable, SerializationFactory, Object, Random
  • free functions: the narrow phase tests in Physics/CollisionDetection.hpp (TestAABBvsAABB and friends, TestCollision, ClosestPointOnSegment, ClosestPointsSegmentSegment) and Math::operator*(const Quaternion&, const Vector3D&)

Object and Random are header only but still need it: they have static inline data members (s_nextUniqueID, generator_). With hidden visibility the engine and the game would each get their own copy of those, which is the kind of bug that does not fail to link, it just quietly hands out duplicate IDs. EventDispatcher has the same pattern with eventHandlers and was already ENGINE_API.

Also dropped ENGINE_API from the class Window; forward declaration in VulkanRenderer.hpp, GCC warns that attributes on an already defined type are ignored.

Why

On Linux every symbol was exported, so a missing ENGINE_API only ever showed up as a link error on Windows. Now Linux behaves like the DLL does, the export table drops from everything (imgui, VMA, glad, all the backend classes) to what is marked, and a forgotten ENGINE_API fails on the platform most of us build on.

To find what was missing I did not just rely on SleakCraft linking: I diffed the strong symbols defined in the engine's object files against nm -D of the built libEngined.so. After this change the only Sleak:: symbols left hidden outside the render backends are MessageBox/ShowMessageBox (from Core/WindowHelper.hpp, only used by Application.cpp) and the private RenderCommandQueue/ResourceManager/*Command classes from include/private. SleakSims, SleakEngine-Empty and SleakEngine-FPP only include Core/, Math/, Runtime/, Lighting/, Camera/, Events/, UI/ and Memory/ public headers and none of them touch those hidden names, so they should link the same as before. I did not build them though.

The diff in a few headers (Random.hpp, Quaternion.hpp, File.hpp, Object.hpp, Timer.hpp, CollisionDetection.hpp) is bigger than the one word change, that is git clang-format reindenting the class body once the class line was touched.

Warning count, GCC 16 Debug, SleakCraft tree: 769 unique diagnostics from engine code. 723 of those are -Wswitch from three switches over KEY_CODE (Application.cpp:292, FreeLookCameraControllerComponent.cpp:148 and :160), one per unhandled enumerator. The other 46: 29 -Wunused-parameter (mostly ECS/Component.hpp and Runtime/Texture.hpp default virtuals), 9 -Wreorder (Object, GameObject, Component), 4 -Wunused-variable, and one each of -Wsign-compare (List.hpp), -Wignored-qualifiers (Queue.hpp), -Wunused-but-set-variable (Matrix.hpp) and -Wdelete-incomplete (RefPtr.hpp:76). -Wpedantic added zero on GCC, so I kept it. Clang and MSVC counts I have not looked at.

Not covered here: fixing those warnings. The -Wdelete-incomplete one in RefPtr is the only one that looks like a real bug (deleting through an incomplete type is UB when the destructor is not trivial) and deserves its own PR.

How it was verified

  • Builds on Linux
  • Builds on Windows (CI only)
  • Ran the sample scene on Vulkan
  • Ran the sample scene on OpenGL

SleakCraft built against this branch (Debug, Ninja), no undefined references. Ran under xvfb with the x11 SDL driver and -world citest -seed 42 -rd 4: OpenGL on Mesa llvmpipe for 90s (world created) and Vulkan on the RTX 4050 for 60s (world loaded), no errors, both killed by the timeout. Game side logging through Logger::GetLogger() still shows up in the log. I did not drive any input in the headless runs.

Windows: ENGINE_API on the new classes means they are now dllexport/dllimport there too, which only adds exports, but I could not compile it here. Since this targets the #194 branch the PR checks do not run on it, so I kicked the CI workflow by hand on the branch: Linux Debug/Release/Clang and Windows Debug/Release all build (https://github.com/CanReader/SleakEngine/actions/runs/37221196589). Format, clang-tidy and the downstream game job only run on PRs to main, so those will run once this is retargeted.

Checklist

  • Public headers documented with /// comments
  • No new includes from src/ or include/private/ in public headers
  • No game-specific vocabulary added to engine API

Warnings apply to engine sources only, vendors are added as SYSTEM. ENGINE_API now means default visibility outside Windows, and the classes and free functions that were missing it get it.
@CanReader
CanReader changed the base branch from build/version-install-export to main October 8, 2026 09:26

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant