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

swift-corefoundation: locally shadowed symbols are incorrectly ignored #238791

Closed
emilazy opened this issue Jun 20, 2023 · 0 comments
Closed

swift-corefoundation: locally shadowed symbols are incorrectly ignored #238791

emilazy opened this issue Jun 20, 2023 · 0 comments
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: stdenv Standard environment

Comments

@emilazy
Copy link
Member

emilazy commented Jun 20, 2023

If you create a static library with a symbol that shadows one in CoreFoundation and then link with both -framework CoreFoundation and that library, the macOS system toolchain will use the one from your static library. Linking with our swift-corefoundation, however, will result in incorrect behaviour. Currently, as of a few days ago, it causes a crash at runtime due to a broken rpath hook; a fix for this is being worked on. Before that, however, we get an arguably worse result: the symbol is resolved from swift-corefoundation instead, leading to the potential of silently incorrect behaviour. This is reproducible as far back as I can go (21.05; it seems earlier versions can't build executables on Ventura).

If darwin.apple_sdk.frameworks.CoreFoundation is used to replace swift-corefoundation then we get correct behaviour even with the nixpkgs toolchain, and if swift-corefoundation is passed in to the system toolchain we get incorrect behaviour. Therefore the issue must be either with the swift-corefoundation package itself, or some behaviour in the toolchain or OS that is special-casing the system CoreFoundation but not ours, rather than being a general linking difference between our toolchain and Apple's. (The former is not wholly implausible, given the dyld cache shenanigans recent macOS releases have.)

Note that this probably only applies to x86_64-darwin; on aarch64-darwin we currently use the system CoreFoundation exclusively (although there's a TODO to fix that). It may apply to dynamic libraries as well as static ones, but I didn't test that.

I have pushed a simple test case to https://github.com/emilazy/nixpkgs-corefoundation-linking-issue; it has a flake with packages to demonstrate all these variations in behaviour and a test.bash script which will build and show output for all of them. (Sorry, I didn't feel like handling pinning multiple nixpkgs for the non-flake case, but there's a default.nix you can manually feed things into if you don't want to use flakes.)

I discovered this while trying to fix e2fsprogs on x86_64-darwin; it seems that before the hook issue broke the build entirely it had been mixing the old vendored CoreFoundation version of its UUID library with its more featureful local copy. That doesn't seem to break anything, but it makes me uneasy.

cc @toonn @reckenrode

@emilazy emilazy added 0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: non-nixos 6.topic: stdenv Standard environment labels Jun 20, 2023
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 24, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 24, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 24, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 27, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 27, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 27, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 27, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 27, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 27, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 28, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 29, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 29, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 29, 2023
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.

The following changes have been made to the build:

* CF uses cmake instead of the build script; and
* CF links against icu from nixpkgs instead of darwin.ICU.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jun 30, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jul 2, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jul 2, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jul 2, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jul 2, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jul 2, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
reckenrode added a commit to reckenrode/nixpkgs that referenced this issue Jul 2, 2023
Switching the build system to cmake makes it easier to make changes to
the build (particularly which dependencies to link). It also removes a
lot of manual build steps and fixes the issue identified by @emilazy in
NixOS#238791.

Fixes NixOS#238791.
@vcunat vcunat closed this as completed in aeb53a8 Jul 15, 2023
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 6.topic: stdenv Standard environment
Projects
None yet
Development

No branches or pull requests

1 participant