WIP: Build: a lift that lost functions is not reused; one build at a time on a work folder (#890) #918
Closed
amaralthalesalves wants to merge 3 commits from
fix/lift-incomplete-not-reused into main
pull from: fix/lift-incomplete-not-reused
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2756
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!918
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/lift-incomplete-not-reused"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs #890 (and the v2.0.3 report in #733).
What the report points to. The v2.0.4 and v2.0.5 AppImages ship byte-identical
work/files (hot_funcs.txt,chunks.txt, the profile). Between those tags the lift code changed only in ways that don't affect its output: thelifted_cregex refactor and howmadeis held inchunks.write. So the difference comes from the state of the work folder, not the version.With the shipped
chunks.txt:code_NNN_k.cparts, which is 80 files, v2.0.4's count. The reporter's 65 is 57 + 8 with no parts at all.A mechanism that gives exactly that (reproduced). Only
split_bigdeletes parts. Suppose two lifts write into onesa/genat once. Lift A cuts its big chunks into parts. Lift B'ssplit_bigthen reads those already-cut chunks, finds them small, and deletes every part as stale. The result:functions.txtand called from other chunks anda64_table.c, but defined nowhere;f_symbols, and "20" is just lld's default--error-limit.Nothing stops two builds on one work folder on Linux, because
stop_stray_compilersacts on Windows only. A second build can come from another builder window, the game's update offer (--update) or the command line. I couldn't confirm that two builds actually overlapped on the reporter's PC; the lift section of their first v2.0.5 log would tell (nochunks: code_0NN.c (… MB) in N partslines).Why it never recovers (shown).
write_lift_keyvouched for the broken C, and every later build has the same key, solifted_beforeskipped the lift. Clearing both object caches couldn't help, because the broken C is never regenerated.The change
make_game.undefined_functions(gen)lists the functionsfunctions.txtnames that nocode_*.cdefines. It useslifted_c.DEF_BYTES, which matches from the preceding newline and is about 10× faster thanHEAD_BYTES(0.07 s vs 0.83 s on 181 MB).lifted_beforealso requires that nothing is missing, so a folder already broken this way, like the reporter's, recovers by itself on the next build. This adds a scan of the lifted C (about 1.4 GB) to a build that skips the lift, roughly a second or two.lock_worktakes a non-blockingflockon<work>/.build_lockfor the life ofmake_game, and a second build on the same work folder stops with a message. Python's fds are non-inheritable, so compilers don't hold the lock.Tests.
tests/test_lift_complete.pyis game-free: it uses the realchunks.write,Lifter.writeandsplit_hot, with no native translator needed. It:lifted_beforerefuses the folder;Against main's
make_game.pyit fails (noundefined_functions); on this branch it printsok.tests/run_all.py lift make_game chunkgives 4 passed. An earlier run of related checks (test_parallel_emit,test_mem_gate,test_build_log,test_finish_output,test_build_times…) gave 11 passed.Not verified. I haven't run a real game build. The reporter's trigger (two builds at once) is inferred. The detection and self-healing don't depend on it: any lift that leaves a listed function undefined is no longer reused.
Workaround for the reporter now: delete
<work>/sa/gen/.lift_key(orsa/gen), then build once with no other build running.Moving this to draft: the cause is inferred from the reporters' logs, and I haven't reproduced it on their setup or tested it with a real game build. The change and its game-free test hold as described. It needs confirmation from someone who can build the game (ideally a reporter of the linked issue) before it's ready.
Rebased on current main (
8b2e1d3). There were no conflicts, andtest_lift_completeplus the lift / make_game / chunk / cache tests pass. Since #55abe59deletessa/after a build by default, the extraundefined_functionsscan inlifted_beforeonly runs whenHOOKSHOT_KEEP_BUILD_FILES=1. The check right after the lift is unchanged. It's still a draft until someone confirms it with a real build.About the red "Python source checks" here: the only failure is
tests/test_program_answer_domains.py(use of undeclared identifier 'answers_in'in its C++ fixture). It fails the same way on main at8b2e1d3, run 42588468881, on both Linux and Windows. This PR only touchesnx2/make_game.py,nx2/lifted_c.pyandtests/test_lift_complete.py, which passes. The other 129 checks pass.Superseded since v2.0.10: a failed compile or link now forgets the lift, and a new lift clears the earlier lifted C first (issues 1176 and 1197), so a lift that lost functions is not reused. This draft also fails CI. Closing; thanks for tracking #890 down!