Skip to content
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

Two CoreFoundations lead to redefinition errors #189687

Closed
tjni opened this issue Sep 4, 2022 · 6 comments
Closed

Two CoreFoundations lead to redefinition errors #189687

tjni opened this issue Sep 4, 2022 · 6 comments
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin

Comments

@tjni
Copy link
Contributor

tjni commented Sep 4, 2022

Describe the bug

It seems that some packages, such as cargo-watch, depend on CoreFoundation. When they are compiled, there are two different CoreFoundations added to the compiler's path (which can be verified by observing NIX_CFLAGS_COMPILE).

One of them was built with stdenv-darwin. The other was built with bootstrap-stage4-stdenv-darwin. In apple-sdk-11.0, CoreFoundation depends on libobjc, for which two different versions being present produce redefinition errors:

/nix/store/ppiqn1bal7bzix25lj5zxzcq50113qk0-libobjc-11.0.0/include/objc/module.modulemap:1:8: error: redefinition of module 'ObjectiveC'
module ObjectiveC [system] [extern_c] {
       ^
/nix/store/wdnnmrk0wvdws80m3ad3byp86zzl11dq-libobjc-11.0.0/include/objc/module.modulemap:1:8: note: previously defined here
module ObjectiveC [system] [extern_c] {

I think the bootstrap-stage4-stdenv-darwin CoreFoundation comes from extraBuildInputs in stdenv-darwin. I'm not sure what to do about it, however.

Steps To Reproduce

Steps to reproduce the behavior:

  1. On aarch64-darwin, nix build .#cargo-watch.

Expected behavior

I don't think two versions of CoreFoundation should be added to the compile path.

Notify maintainers

/cc @NixOS/darwin-maintainers

@veprbl veprbl added the 6.topic: darwin Running or building packages on Darwin label Sep 4, 2022
@eqyiel
Copy link
Contributor

eqyiel commented Sep 10, 2022

A related thread and workaround #160876 (comment)

@tjni
Copy link
Contributor Author

tjni commented Sep 12, 2022

The ideal state would be for CoreFoundation to appear once when compiling and linking. Today, CoreFoundation appears once from stdenv and again when some derivation depends on linking to the (impure) system CoreFoundation. In addition, dependencies of CoreFoundation (in this case, libobjc on aarch64-darwin) can appear twice for the same reason. It is this repeating of libobjc that surfaces the redefinition errors.

As an intermediate step, I currently envision removing CoreFoundation from stdenv and declaring the dependency explicitly in derivations that need it. The removed CoreFoundation is from a bootstrap stage, while the explicit one won't be, which should solve the redefinition errors because there will only be one libobjc available.

The CoreFoundation in the stdenv is currently pure, so we'd need to introduce a PureCoreFoundation derivation (which exists, currently called CF by convention) for this purpose.

I plan to start experimenting with this.

/cc @LnL7 @thefloweringash @toonn in case they already know this won't work or have other ideas in the meantime

@tjni
Copy link
Contributor Author

tjni commented Sep 12, 2022

Encountered a problem with this approach. Building the frameworks depends on MacOSX-SDK, which transitively depends on fetching patches using curl, but curl needs CoreFoundation to build.

@toonn
Copy link
Contributor

toonn commented Sep 12, 2022

I wonder if this conditional is trying to fix the same root problem? This is coming from #189977.

@tjni
Copy link
Contributor Author

tjni commented Sep 12, 2022

Great find. I have hopes that will resolve the errors seen in cargo-watch.

@tjni
Copy link
Contributor Author

tjni commented Sep 22, 2022

Closing this because #191235 was merged into staging. To me, it's still ugly that two copies of CoreFoundation can exist on the include path, but I don't have a viable alternative and the underlying problem is now resolved.

@tjni tjni closed this as completed Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

No branches or pull requests

4 participants