Skip to content

[native_toolchain_c] Add linking for macOS #2360

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

Merged
merged 4 commits into from
Jun 16, 2025

Conversation

goderbauer
Copy link
Contributor

Towards #1376

This enables linking for MacOS targets on MacOS hosts.

Copy link

github-actions bot commented Jun 13, 2025

PR Health

Changelog Entry ✔️
Package Changed Files

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.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/jni/lib/src/third_party/generated_bindings.dart
pkgs/native_doc_dartifier/example/native_doc_dartifier_example.dart
pkgs/native_doc_dartifier/lib/native_doc_dartifier.dart
pkgs/native_doc_dartifier/lib/src/native_doc_dartifier_base.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

Copy link

Package publishing

Package Version Status Publish tag (post-merge)
package:code_assets 0.19.4 already published at pub.dev
package:data_assets 0.19.1 already published at pub.dev
package:ffi 2.1.4 already published at pub.dev
package:ffigen 19.1.0-wip WIP (no publish necessary)
package:hooks 0.19.5 already published at pub.dev
package:hooks_runner 0.21.0 already published at pub.dev
package:jni 0.14.2 already published at pub.dev
package:jnigen 0.15.0-wip WIP (no publish necessary)
package:native_doc_dartifier 0.0.1-pre already published at pub.dev
package:native_toolchain_c 0.16.4 ready to publish native_toolchain_c-v0.16.4
package:objective_c 8.1.0-wip WIP (no publish necessary)
package:swift2objc 0.0.1-wip WIP (no publish necessary)
package:swiftgen 0.0.1-wip WIP (no publish necessary)

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@goderbauer
Copy link
Contributor Author

The breaking check still has problems. I verified locally that this isn't a breaking change.

@dcharkes
Copy link
Collaborator

The breaking check still has problems. I verified locally that this isn't a breaking change.

I've filed #2361.

@coveralls
Copy link

coveralls commented Jun 13, 2025

Coverage Status

coverage: 88.027% (+0.03%) from 88.001%
when pulling 4a8137d on goderbauer:macos-linker
into 5eadfaf on dart-lang:main.

@goderbauer goderbauer requested review from dcharkes and mosuem June 13, 2025 12:27
Copy link
Collaborator

@dcharkes dcharkes left a comment

Choose a reason for hiding this comment

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

Thanks @goderbauer !

) {
final includeAllSymbols = _symbolsToKeep == null;

if (targetOS == OS.macOS) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this should be written as a switch on target OS (which then has both the Android and Linux cases got to the same block). Early return for MacOS and combining all other OSes seems somewhat weird.

}) async {
assert((targetOS != OS.android) == (androidTargetNdkApi == null));
assert((targetOS != OS.macOS) == (macOSTargetVersion == null));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we consider throwing argument errors instead of doing asserts?

Especially because below we check macOSTargetVersion != null instead of targetOS == OS.macOS.

// See https://github.com/dart-lang/native/issues/1376.
@TestOn('linux')
@TestOn('linux || mac-os')
Copy link
Collaborator

Choose a reason for hiding this comment

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

(Hm, they should have made a bunch of const objects and an Or([Linux(), MacOS()]) class instead of going for strings. How do we know if this syntax is correct and we're not just skipping the test everywhere because of wrong syntax. 😄 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was paranoid about that as well and double-checked that the test runs. :D

@goderbauer goderbauer merged commit 92e243f into dart-lang:main Jun 16, 2025
18 checks passed
@goderbauer goderbauer deleted the macos-linker branch June 16, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants