-
Notifications
You must be signed in to change notification settings - Fork 69
[native_toolchain_c] Add linking for Android #2347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR HealthChangelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
|
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
84b1b48
to
ca6c274
Compare
Hm, it's not clear to me why the bot wants the version to be bumped to 0.17.0 |
You should be able to repro it with the |
Thank you! I am pretty sure that the tool is wrong here based on what it has identified as a breaking change in a local run:
The Edit: It looks like the |
ca6c274
to
330b8db
Compare
It does indeed check out the package from pub. See the discussion here: bmw-tech/dart_apitool#216 The packages on pub.dev should work, they are used in the flutter template and flutter integration tests. It's fishy that it fails. (Yeah indeed just apply the label for now.) |
@@ -53,10 +53,12 @@ class CLinker extends CTool implements Linker { | |||
required LinkOutputBuilder output, | |||
required Logger? logger, | |||
}) async { | |||
if (OS.current != OS.linux || input.config.code.targetOS != OS.linux) { | |||
const supportedTargetOSs = [OS.linux, OS.android]; | |||
if (!supportedTargetOSs.contains(input.config.code.targetOS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This no longer checks if the hostOS is Linux if the targetOS is Linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was assuming that we only check for combinations that should work, but currently don't because they are still WIP - similarly to how cbuilder.dart is also not checking that you can only target linux from linux.
pkgs/native_toolchain_c/test/clinker/treeshake_cross_android_test.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that users need to have clang or similar installed? Linux will have ld
preinstalled, but not clang.
In theory, it does not require clang on linux and I double checked that in practice everything works if the compiler driver to be used resolves to gcc, which should be installed by default on Linux. However, the native_toolchain_c package currently hard-codes the use of clang on linux systems if host and target OS and architecture match:
Not sure why this is done. When I remove this and let it instead fall through to select the approriate gcc on linux (see below) it just works as expected:
@dcharkes Since you added this selection code originally, do you have any insights into this? Is it on purpose that we force clang on linux if you don't cross-compile? If yes, do we consider it a requirement that clang is installed on linux if one wants to use the |
No. But we haven't implemented fallback tools yet:
The tool recognizer works with both clang and gcc if passed in in the
We do have a requirement that we use the compiler/linker/archiver that belong together. We shouldn't be using a linker from a different compiler toolchain. So the fallback logic can't be separate for the compiler/linker. So we might need to introduce something like a |
This PR actually simplifies this then since it removes calling the linker directly and instead goes through clang or gcc or whatever compiler driver is available. I am submitting this as is then since #20 is a separate open issue regarding clang vs. gcc on Linux. |
Towards #1376
This enables linking for Android on Windows, Linux, and MacOS hosts.
With this PR the linker is no longer invoked directly. Instead, it is invoked via the compiler driver (clang, etc.), which has the advantage that we don't have to hand-translate the arguments to the format the linker expects them to be. The compiler driver is doing that for us and we can mostly reuse the compiler driver invocation.
Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.