Skip to content

Conversation

@js-9
Copy link
Contributor

@js-9 js-9 commented Dec 5, 2025

Changes

This adds support for and enables by default parallel linking for IL2CPP builds.
IL2CPP builds spend a lot of time in the linking stage, since the compilation step is already parallel. This updates the build to make unity use parallel linking, which can significantly speed up builds, especially if the library and incremental build cache is used, in which cases linking is where most of the build time is spent.

  • Introduced 'enableParallelLinking' input in action.yml to control parallel linking.
  • Updated Builder.cs to apply parallel linking settings based on the new input.
  • Modified build scripts for macOS, Ubuntu, and Windows to include the parallel linking option.

Successful Workflow Run Link

I've been using this in our private repo for a bit and it seems to work, although ios, osX and Android builds are untested.

TODOs

If people are interested in this change I'll update documentation and README as well.

  • Update README
  • Update Documentation

Checklist

  • Read the contribution guide and accept the
    code of conduct
  • Docs (If new inputs or outputs have been added or changes to behavior that should be documented. Please make a PR
    in the documentation repo)
  • Readme (updated or not needed)
  • Tests (added, updated or not needed)

Summary by CodeRabbit

  • New Features
    • Added an optional enableParallelLinking input to the Unity - Builder Action (enabled by default) to allow parallel IL2CPP linking for faster builds.
    • The setting is exposed to build environments via an ENABLE_PARALLEL_LINKING variable so build tools on all supported platforms (including macOS runners) can act on it.

✏️ Tip: You can customize this high-level summary in your review settings.

* Introduced 'enableParallelLinking' input in action.yml to control parallel linking.
* Updated Builder.cs to apply parallel linking settings based on the new input.
* Modified build scripts for macOS, Ubuntu, and Windows to include the parallel linking option.
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Cat Gif

@coderabbitai
Copy link

coderabbitai bot commented Dec 5, 2025

📝 Walkthrough

Walkthrough

Adds a new boolean action input enableParallelLinking that flows from the action input into the Input model, BuildParameters, and is exposed as ENABLE_PARALLEL_LINKING in environment setup for Docker and macOS platform setup.

Changes

Cohort / File(s) Summary
Action Configuration
action.yml
Added optional input enableParallelLinking (default: 'true') to configure parallel linking for IL2CPP builds.
Input & Parameter Models
src/model/input.ts,
src/model/build-parameters.ts
Added static get enableParallelLinking(): boolean to Input; added enableParallelLinking: boolean to BuildParameters and propagated the input in BuildParameters.create().
Environment Setup
src/model/image-environment-factory.ts,
src/model/platform-setup/setup-mac.ts
Added ENABLE_PARALLEL_LINKING environment variable entry derived from buildParameters.enableParallelLinking and passed to Docker/platform setup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Consistent pattern across a small set of files (input → model → env).
  • Review focus: correct default parsing in Input, correct propagation in BuildParameters.create(), and correct string conversion when setting environment variables.
  • Files to double-check:
    • src/model/input.ts (input parsing and default)
    • src/model/build-parameters.ts (factory propagation)
    • src/model/image-environment-factory.ts / src/model/platform-setup/setup-mac.ts (env var naming and value type)

Possibly related PRs

Suggested reviewers

  • webbertakken
  • davidmfinol

Poem

🐰 A tiny hop, a toggle so bright,
From action to env it skips into flight,
Linking in parallel, faster and spry,
I nudge the build, then wink my eye,
Hoppity speed — watch compile fly! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding support for parallel linking in IL2CPP builds, which aligns with all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description includes Changes, Workflow Run Link, and Checklist sections, but lacks Related Issues and Related PRs sections from the template. However, core information is present and complete.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.43%. Comparing base (0c82a58) to head (ff72fec).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #764      +/-   ##
==========================================
+ Coverage   38.37%   38.43%   +0.05%     
==========================================
  Files          78       78              
  Lines        3171     3174       +3     
  Branches      665      666       +1     
==========================================
+ Hits         1217     1220       +3     
  Misses       1809     1809              
  Partials      145      145              
Files with missing lines Coverage Δ
src/model/build-parameters.ts 90.00% <ø> (ø)
src/model/image-environment-factory.ts 4.00% <ø> (ø)
src/model/input.ts 89.17% <100.00%> (+0.21%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/model/input.ts (1)

146-150: Boolean getter works; consider whether default should be true everywhere

The getter follows the existing pattern for manualExit / enableGpu and will correctly return true when the action input is 'true'. In GitHub Actions runs, the action.yml default 'true' means this flag is enabled by default, but in non‑GitHub contexts (e.g. CLI/CloudRunner without explicit input) the ?? false fallback makes the default effectively false.

If you want “parallel linking on by default” consistently across all entrypoints, consider defaulting the fallback to 'true' instead:

const input = Input.getInput('enableParallelLinking') ?? 'true';
return input === 'true';
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c82a58 and 1c09f7a.

⛔ Files ignored due to path filters (6)
  • dist/default-build-script/Assets/Editor/UnityBuilderAction/Builder.cs is excluded by !**/dist/**
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • dist/platforms/mac/steps/build.sh is excluded by !**/dist/**
  • dist/platforms/ubuntu/steps/build.sh is excluded by !**/dist/**
  • dist/platforms/windows/build.ps1 is excluded by !**/dist/**
📒 Files selected for processing (5)
  • action.yml (1 hunks)
  • src/model/build-parameters.ts (2 hunks)
  • src/model/image-environment-factory.ts (1 hunks)
  • src/model/input.ts (1 hunks)
  • src/model/platform-setup/setup-mac.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-12-05T17:12:46.110Z
Learnt from: GabLeRoux
Repo: game-ci/unity-builder PR: 0
File: :0-0
Timestamp: 2024-12-05T17:12:46.110Z
Learning: For Unity version 6 and above, the -activeBuildProfile parameter cannot be used together with -buildTarget parameter as they are mutually exclusive. Build profiles are a new feature that encapsulate build settings including the target platform.

Applied to files:

  • action.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Tests
🔇 Additional comments (5)
action.yml (1)

46-49: New enableParallelLinking input is well‑named and consistent

Input name, default, and description are clear and align with the downstream Input.enableParallelLinking / ENABLE_PARALLEL_LINKING wiring. No issues from the action metadata side.

src/model/platform-setup/setup-mac.ts (1)

197-197: Mac host env wiring for ENABLE_PARALLEL_LINKING looks correct

Using buildParameters.enableParallelLinking.toString() matches the existing patterns for MANUAL_EXIT / ENABLE_GPU and keeps host‑side scripts in sync with the Docker env naming.

src/model/image-environment-factory.ts (1)

47-47: Docker env propagation of ENABLE_PARALLEL_LINKING is consistent

Adding { name: 'ENABLE_PARALLEL_LINKING', value: parameters.enableParallelLinking } alongside ENABLE_GPU cleanly exposes the new flag to the container; the existing getEnvVarString logic will stringify the boolean correctly.

src/model/build-parameters.ts (2)

37-37: New enableParallelLinking property fits existing parameter model

Boolean field placement next to enableGpu matches the existing configuration style and keeps the model coherent.


166-166: Propagation from Input.enableParallelLinking into BuildParameters is correct

Passing Input.enableParallelLinking through in create() ensures all consumers (Docker env, mac setup, etc.) receive the new flag without extra plumbing.

@js-9
Copy link
Contributor Author

js-9 commented Dec 5, 2025

Actionable comments posted: 0
🧹 Nitpick comments (1)

src/model/input.ts (1)> 146-150: Boolean getter works; consider whether default should be true everywhere

The getter follows the existing pattern for manualExit / enableGpu and will correctly return true when the action input is 'true'. In GitHub Actions runs, the action.yml default 'true' means this flag is enabled by default, but in non‑GitHub contexts (e.g. CLI/CloudRunner without explicit input) the ?? false fallback makes the default effectively false.
If you want “parallel linking on by default” consistently across all entrypoints, consider defaulting the fallback to 'true' instead:

const input = Input.getInput('enableParallelLinking') ?? 'true';
return input === 'true';

📜 Review details

The nitpick comment here has been addressed in onibi-gg/unity-builder@ff72fec .

@timcassell
Copy link

Is that flag documented somewhere? I couldn't find it from a google search.

It would be nice to add it to unity-test-runner also to speed up standalone builds.

@js-9
Copy link
Contributor Author

js-9 commented Dec 5, 2025

Is that flag documented somewhere? I couldn't find it from a google search.

It would be nice to add it to unity-test-runner also to speed up standalone builds.

This only has effect with IL2CPP since mono builds do not require a linking stage. I'd be surprised if the test runner used IL2CPP, I can't see much benefit to it except in very limited situations where code would have different results on mono vs. IL2CPP.
Anyways, the flags are documented here: https://docs.unity3d.com/6000.2/Documentation/Manual/handling-il2cpp-additional-args.html

@timcassell
Copy link

I use it to test il2cpp builds for my library. The build part takes up half the test time, so any speedup would be appreciated. 🙂

@js-9
Copy link
Contributor Author

js-9 commented Dec 5, 2025

I use it to test il2cpp builds for my library. The build part takes up half the test time, so any speedup would be appreciated. 🙂

Ah. Does the test-runner have a separate repo and build script? This same technique should work on that too, I'd guess.

@js-9
Copy link
Contributor Author

js-9 commented Dec 5, 2025

BTW I need to update the patch, since this looks at the targetplatform to set platform-specific linker flags, but I need to change it to look at the build platform since that is where the compiler differences are.

EDIT: this is done

@timcassell
Copy link

timcassell commented Dec 5, 2025

https://github.com/game-ci/unity-test-runner/blob/main/dist/platforms/ubuntu/run_tests.sh

@js-9
Copy link
Contributor Author

js-9 commented Dec 5, 2025

I'll see what I can do.

@js-9
Copy link
Contributor Author

js-9 commented Dec 6, 2025

For visibility: game-ci/unity-test-runner#300 (comment)

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