Repository navigation
Link a default for the embedded-assets prepare hook - #7
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
dashersw
left a comment
There was a problem hiding this comment.
Reviewed alongside geastack/core#75. The change is correct: main/*.cpp is globbed into every Windows build (build-windows.mjs:506), so the new /alternatename default is always linked. The no-bundle weak definition the generator now emits, and the strong one it emits for file-backed bundles, both replace it as the comment describes.
1. It has not run anywhere. No workflow in this repo runs on Windows, so hook-defaults.test.mjs skips in CI as well as on macOS. Someone needs to run it on a Windows box with clang-cl and lld-link before merging. Until then this change and core#75's Windows half are both source-only.
2. Merge order. I agree these merge together. If this lands first, gea_app_entry.cpp still declares the hook __attribute__((weak)), so a clang-cl weak external with its own default meets the new /alternatename. The file header says that pairing is a duplicate on COFF. That's worth confirming on Windows, or avoiding by landing core#75 first or in the same release.
3. The test doesn't fully cover the new hook. prepare only gets the default case and the program's weak definition. There's no app-override fixture for it (the override run still prints prepare 0 from program.cpp) and no duplicate-symbol check, unlike gea_embedded_asset_lookup. The real generator also emits a strong gea_embedded_assets_prepare for file-backed bundles, and a strong-definition fixture would cover that path.
Nit: #include <cstddef> in win32_hook_defaults.cpp is unused (it predates this PR).
|
Pushed 3f33699, updated for core 81cbe9f, which now gives every non-bundle app a weak
Nit: removed the unused include. |
|
Ran
|
core now references gea_embedded_assets_prepare through GEA_PROGRAM_HOOK, which this target compiles as an ordinary reference. build-windows.mjs adds the generated assets unit only when it exists, and without it nothing defines the hook, so it gets an /alternatename default like the other hooks. The default returns true: with no file-backed assets there is nothing to prepare.
The generator now defines a weak gea_embedded_assets_prepare for apps without file-backed assets (core 81cbe9f) and a strong one for apps with them. A bundle fixture stands in for the strong definition, which must replace the program's weak one, the app override now defines it too, and two strong definitions must still fail to link. Also drop an unused <cstddef> include.
3f33699 to
856ba96
Compare
dashersw
left a comment
There was a problem hiding this comment.
Thanks for the Windows run. Merging together with geastack/core#75.
Companion to geastack/core#75.
Problem
Core 81cbe9f gives every non-bundle app a weak
gea_embedded_assets_prepare, while core declares the reference with a plain__attribute__((weak)); on COFF that pair is a duplicate. geastack/core#75 declares it withGEA_PROGRAM_HOOK, so this target (/DGEA_LINKED_HOOK_DEFAULTS=1) references it as an ordinary symbol.build-windows.mjsaddsgea_embedded_assets_generated.cpponly when it exists, and a build without it would then have no definition.Change
win32_hook_defaults.cpp:gea_win32_default_embedded_assets_prepare()returns true and is linked through/alternatename, like the other hook defaults. Also drops an unused<cstddef>include.hook-defaults.test.mjsand its fixtures: the framework fixture calls the hook.program.cppdefines it weakly, as the generator does;app_override.cppand a newbundle_prepare.cppdefine it strongly. Theoverrideandbundleruns expect a strong definition to replace the program's, andprepare-duplicateexpects two strong ones to fail.Tests
Not run on Windows. On macOS I compiled this repo's
win32_hook_defaults.cppand the fixtures with clang-cl, using the test's flags minus/MD, and linked each case ofhook-defaults.test.mjswith lld-link 23.1.3. There is no CRT here, soprintf,putsand the/GScookie are stubs, and the executables were not run; each hook's provider comes from the linker map. All six cases match the test's expectations. With main'swin32_hook_defaults.cpp, thedefaultscase fails withundefined symbol: gea_embedded_assets_prepare.Please run
hook-defaults.test.mjson Windows before merging.Merge order
Land this together with geastack/core#75. On its own, with core's plain weak reference, it does not conflict: a strong definition still wins, and with no generated assets unit the reference stays null.
Summary by CodeRabbit
Bug Fixes
Tests