Skip to content

zip: fix build with GCC 14 - #359020

Merged
emilazy merged 2 commits into
NixOS:stagingfrom
FliegendeWurst:gcc14-round-2
Nov 26, 2024
Merged

emilazy merged 2 commits into
NixOS:stagingfrom
FliegendeWurst:gcc14-round-2

Conversation

@FliegendeWurst

@FliegendeWurst FliegendeWurst commented Nov 25, 2024 •

Copy link
Copy Markdown
Member

GCC 14 breaks the package

ref. #356812

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@nix-owners
nix-owners Bot requested a review from RossComputerGuy November 25, 2024 14:52
@emilazy

emilazy commented Nov 25, 2024

Copy link
Copy Markdown
Member

I’d actually like to merge this pretty promptly as I’ve had a few things blocked on OpenJDK builds. But it’s kind of awful that we’re just downgrading the compilation to sweep some UB further under the rug – can you add a comment that -O3 exposes undefined behaviour with GCC 14, that it manifested in a broken openjdk8 build, and a TODO to at least pretend that someone will investigate this properly one day? Because it’s always possible that GCC 15 starts exposing it at -O2…

@FliegendeWurst

Copy link
Copy Markdown
Member Author

So... I was apparently foolish enough to assume that "no more of the new warnings" = "fixed zip package".
This fix is still not enough. I will investigate further.

There is no maintained fork of zip, right?

@RossComputerGuy

Copy link
Copy Markdown
Member

There is no maintained fork of zip, right?

Afaik, no. Same goes for unzip.

@emilazy

emilazy commented Nov 25, 2024

Copy link
Copy Markdown
Member

@FliegendeWurst

Copy link
Copy Markdown
Member Author

The same error occurs at -O0, and the Gentoo patches do not help.

@RossComputerGuy

Copy link
Copy Markdown
Member

Wouldn't just dropping the optimization flag work?

@FliegendeWurst

Copy link
Copy Markdown
Member Author

Wouldn't just dropping the optimization flag work?

That would be equivalent to -O0, right? Though it looks a bit cleaner.

@FliegendeWurst

Copy link
Copy Markdown
Member Author

I've pushed an alternative approach where we use GCC 13 instead. Not very nice but it works

@FliegendeWurst FliegendeWurst changed the title zip: fix build with GCC 14 zip: build with GCC 13 instead Nov 25, 2024
@emilazy

emilazy commented Nov 25, 2024

Copy link
Copy Markdown
Member

Not sure I feel good about this – if it’s GCC 14 miscompiling the code then we’re in trouble and can expect other issues throughout the tree. OTOH if it’s UB in zip then pinning an old compiler doesn’t seem very sustainable. But maybe it’s the best solution for now…

@FliegendeWurst

Copy link
Copy Markdown
Member Author

I just found https://bugzilla.redhat.com/show_bug.cgi?id=2165653 and will try their patch later. But it doesn't really match our problem.

@FliegendeWurst

Copy link
Copy Markdown
Member Author

Nevermind, we already include that patch.

@emilazy emilazy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This worries me, but I’m okay proceeding with it for now if you split the patches into another commit and adjust the comment.

Comment thread pkgs/by-name/zi/zip/package.nix Resolved
@FliegendeWurst

Copy link
Copy Markdown
Member Author

So I just found another patch: https://sources.debian.org/data/main/z/zip/3.0-14/debian/patches/12-fix-build-with-gcc-14.patch
(please advise where I can get that reproducibly, I can't seem to find it in the Debian Salsa)

Which I want to try out. I was comparing the build logs, and this patch removes some differences.

@FliegendeWurst FliegendeWurst changed the title zip: build with GCC 13 instead zip: fix build with GCC 14 Nov 26, 2024
./fix-memset-detection.patch
# Implicit declaration of `closedir` and `opendir` cause dirent detection to fail with clang 16.
./fix-implicit-declarations.patch
# Buffer overflow on Unicode characters in path names

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This patch was moved below as part of the Gentoo patches.

@emilazy emilazy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Builds on aarch64-linux and aarch64-darwin. Thanks for getting to the root of this! Much happier with this than pinning the compiler.

@emilazy
emilazy merged commit c769838 into NixOS:staging Nov 26, 2024
@Sigmanificient Sigmanificient mentioned this pull request Mar 8, 2025
27 of 28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants