Skip to content

build(windows): use -O3 like Linux/macOS (drop -O0 special case) - #52

Merged
esrrhs merged 1 commit into
masterfrom
fix/windows-optimization-flags
Nov 9, 2026
Merged

esrrhs merged 1 commit into
masterfrom
fix/windows-optimization-flags

Conversation

@esrrhs

@esrrhs esrrhs commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Why

CMakeLists.txt pinned Windows/MinGW to -O0, while Linux and macOS use -O3
(and -O0 only for USE_COV builds). No comment or commit message explains the
exception: git log -S'-O0' -- CMakeLists.txt traces it back to the initial tree,
carried over by 01c2ed23 (Replace the repository with fakelua master).

In practice CMAKE_BUILD_TYPE=Release appends CMAKE_CXX_FLAGS_RELEASE
(-O3 -DNDEBUG) after CMAKE_CXX_FLAGS, so GCC saw
... -g3 -ggdb3 -fPIC -O0 -O3 -DNDEBUG ... and used -O3 anyway. The -O0
only took effect for builds without a build type, which made Windows
inconsistent with Linux and the intent misleading.

Change

  • Remove the IF (WIN32) branch; Windows now shares the ELSE () branch with
    Linux: USE_COV=ON -> -O0, otherwise -O3 (both C and C++).
  • Add a comment documenting the shared policy.
  • Net: 2 insertions, 5 deletions in the root CMakeLists.txt.

Verification (Windows / MSYS2 MINGW64, GCC 14.2, Ninja)

  • Configure: compile flags now contain -O3 and no -O0 (grep FLAGS build.ninja).
  • Full cmake --build of fakelua + flua is run locally and covered by CI.

Note: CMAKE_BUILD_TYPE=Release builds were already effectively -O3 before
this change, so release binaries are unaffected; only unconfigured builds now
get the intended optimization level (with the usual -O3 + -g3 cost in build
time and binary size).

Windows/MinGW was pinned to -O0 while Linux and macOS use -O3 (-O0 only for USE_COV builds). The WIN32 branch has no explanation in history: git log -S'-O0' traces it back to the initial tree, carried over by 01c2ed2 (Replace the repository with fakelua master).

With CMAKE_BUILD_TYPE=Release, CMAKE_CXX_FLAGS_RELEASE appends -O3 after CMAKE_CXX_FLAGS, so the command line was effectively '... -O0 -O3 ...' and GCC used -O3 anyway. The -O0 only applied to builds without a config and made the intent misleading.

Drop the WIN32 branch so Windows shares the same policy as Linux: -O0 for coverage builds, -O3 otherwise.
@esrrhs

esrrhs commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Local verification is complete (Windows / MSYS2 MINGW64, GCC 14.2.0, CMake 3.31.2, Ninja):

  • Configure: build.ninja compile flags now contain -O3 and no -O0.
  • Full cmake --build --parallel 6 (457 targets: fakelua, flua and all CPM deps): passed in 14m7s.
  • Smoke test on the fresh artifacts: flua install_check.lua --once --jit_type=1 -> init ok / fini ok, exit code 0.

No source changes were needed beyond the root CMakeLists.txt. Release builds were already effectively -O3 before this PR, so installed binaries are unaffected; this change makes unconfigured builds consistent and removes the misleading flag.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.75%. Comparing base (6f54d8d) to head (f6afaf2).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #52   +/-   ##
=======================================
  Coverage   89.75%   89.75%           
=======================================
  Files         125      125           
  Lines       27231    27231           
=======================================
  Hits        24441    24441           
  Misses       2790     2790           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@esrrhs
esrrhs merged commit d311143 into master Nov 9, 2026
9 checks passed
@esrrhs
esrrhs deleted the fix/windows-optimization-flags branch November 9, 2026 02:18
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.

2 participants