Skip to content

Conversation

@GregoryConrad
Copy link
Contributor

@GregoryConrad GregoryConrad commented Sep 13, 2025

If the executable dependencies of code_assets are not found in the usual location (next to clang++ on Linux), search for them on the PATH.
This is necessary on some systems, such as NixOS.

Fixes #175311

CC @dcharkes , looks like you're the relevant SME here based on git blame (sorry I keep tagging you in everything...)

Pre-launch Checklist

@github-actions github-actions bot added tool Affects the "flutter" command-line tool. See also t: labels. a: desktop Running on desktop labels Sep 13, 2025
If the executable dependencies of `code_assets` are not found
in the usual location (next to `clang++` on Linux),
search for them on the `PATH`.
This is necessary on some systems, such as NixOS.
@GregoryConrad GregoryConrad marked this pull request as ready for review September 13, 2025 18:11
@dcharkes
Copy link
Contributor

Can you elaborate why this is necessary on NixOS?

The reason I did not do this before is because I want to avoid accidentally combining a compiler and linker from a different toolchain.

Is there a way to verify the set of tools together makes sense if not based on directory structure? Or do we kind of need to blindly trust that the user has a sensible set of tools on PATH?

CC @dcharkes , looks like you're the relevant SME here based on git blame (sorry I keep tagging you in everything...)

Yes, please tag me! I'm happy to receive contributions that make sure Flutter and the code assets work everywhere! 🙏

@GregoryConrad
Copy link
Contributor Author

GregoryConrad commented Sep 14, 2025

The reason I did not do this before is because I want to avoid accidentally combining a compiler and linker from a different toolchain.

Ahh, I was half-thinking about that when I was making my PR (which is why I preserved the current behavior to look in the same directory). LLVM is confusing enough for me, nevermind roping nix into it; just take a peak at all of the available packages for LLVM 20: https://search.nixos.org/packages?channel=unstable&query=llvmPackages_20 -- they all provide slightly different configurations + binaries

Can you elaborate why this is necessary on NixOS?

At least as far as I know, there isn't an "all-in-one" LLVM package that includes every executable, at least that I've seen. See also this issue, which (I think?) seems relevant.

But thanks for poking some more into this, as I think the proper fix might just be to search for other binary names in the same directory as clang++ now.

For example, it looks like llvmPackages_20.clangUseLLVM might be the package we want to go with here for Nix, which provides these binaries, all in the same directory:

$ which clang++
/nix/store/hnn7sg6s3x3zfk8pjxmpslqyj5yy7v1v-clang-wrapper-20.1.6/bin/clang++
$ ls /nix/store/hnn7sg6s3x3zfk8pjxmpslqyj5yy7v1v-clang-wrapper-20.1.6/bin
addr2line@  as@   c++filt@  clang*    cpp*    ld@  objcopy@  ranlib@  strings@
ar@         c++@  cc@       clang++*  gprof@  nm@  objdump@  size@    strip@

So we will need to follow some symbolic links, but that's not a big issue--we also just need to look for ar and ld in the same directory.

I'll go ahead and close this PR and make a new one for that fix, unless you see any issues with that approach. Thanks for poking into this!

github-merge-queue bot pushed a commit that referenced this pull request Sep 16, 2025
Sometimes the necessary binaries `code_assets` expects alongside
`clang++` have differing names than the current code expects (e.g., `ld`
instead of `ld.lld`) on Linux. This change is necessary on some systems
with atypical installs, such as NixOS.

These binaries are gathered by the flutter tool and are eventually sent
to the build hook for native code assets as the `CCompilerConfig`.

Note that the only other reference to `clang`/`clang++` in the linux
build system is where it is used to invoke `cmake`, where they are set
as the values of the `CC`/`CXX` environment variables.

Fixes #175311

CC @dcharkes, this is take two of #175312

> This PR also fixes my CI using only the `llvmPackages_20.clangUseLLVM`
Nix package, for reference

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@GregoryConrad GregoryConrad deleted the native-assets-exec-path branch September 16, 2025 12:30
dixita0607 pushed a commit to dixita0607/flutter that referenced this pull request Sep 17, 2025
Sometimes the necessary binaries `code_assets` expects alongside
`clang++` have differing names than the current code expects (e.g., `ld`
instead of `ld.lld`) on Linux. This change is necessary on some systems
with atypical installs, such as NixOS.

These binaries are gathered by the flutter tool and are eventually sent
to the build hook for native code assets as the `CCompilerConfig`.

Note that the only other reference to `clang`/`clang++` in the linux
build system is where it is used to invoke `cmake`, where they are set
as the values of the `CC`/`CXX` environment variables.

Fixes flutter#175311

CC @dcharkes, this is take two of flutter#175312

> This PR also fixes my CI using only the `llvmPackages_20.clangUseLLVM`
Nix package, for reference

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 2025
Sometimes the necessary binaries `code_assets` expects alongside
`clang++` have differing names than the current code expects (e.g., `ld`
instead of `ld.lld`) on Linux. This change is necessary on some systems
with atypical installs, such as NixOS.

These binaries are gathered by the flutter tool and are eventually sent
to the build hook for native code assets as the `CCompilerConfig`.

Note that the only other reference to `clang`/`clang++` in the linux
build system is where it is used to invoke `cmake`, where they are set
as the values of the `CC`/`CXX` environment variables.

Fixes flutter#175311

CC @dcharkes, this is take two of flutter#175312

> This PR also fixes my CI using only the `llvmPackages_20.clangUseLLVM`
Nix package, for reference

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
Sometimes the necessary binaries `code_assets` expects alongside
`clang++` have differing names than the current code expects (e.g., `ld`
instead of `ld.lld`) on Linux. This change is necessary on some systems
with atypical installs, such as NixOS.

These binaries are gathered by the flutter tool and are eventually sent
to the build hook for native code assets as the `CCompilerConfig`.

Note that the only other reference to `clang`/`clang++` in the linux
build system is where it is used to invoke `cmake`, where they are set
as the values of the `CC`/`CXX` environment variables.

Fixes flutter#175311

CC @dcharkes, this is take two of flutter#175312

> This PR also fixes my CI using only the `llvmPackages_20.clangUseLLVM`
Nix package, for reference

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
lucaantonelli pushed a commit to lucaantonelli/flutter that referenced this pull request Nov 21, 2025
Sometimes the necessary binaries `code_assets` expects alongside
`clang++` have differing names than the current code expects (e.g., `ld`
instead of `ld.lld`) on Linux. This change is necessary on some systems
with atypical installs, such as NixOS.

These binaries are gathered by the flutter tool and are eventually sent
to the build hook for native code assets as the `CCompilerConfig`.

Note that the only other reference to `clang`/`clang++` in the linux
build system is where it is used to invoke `cmake`, where they are set
as the values of the `CC`/`CXX` environment variables.

Fixes flutter#175311

CC @dcharkes, this is take two of flutter#175312

> This PR also fixes my CI using only the `llvmPackages_20.clangUseLLVM`
Nix package, for reference

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C Compiler dependencies for code_assets cannot always be found on all Linux systems in current implementation

2 participants