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

Improve SDL setup hook #254465

Merged
merged 12 commits into from
Mar 14, 2024
Merged

Improve SDL setup hook #254465

merged 12 commits into from
Mar 14, 2024

Conversation

sergv
Copy link
Contributor

@sergv sergv commented Sep 10, 2023

Summary

SDL setup hook does more work that required by putting more entries into SDL_LIB_PATH than needed. This contributes to bloated environment that leads to #41340.

Details

Before f7fdc99 the SDL setup hook looked like this (literally it was a bit different but logically SDL_LIB_PATH was modified only when SDL_PATH was too) :

addSDLPath () {
  if [ -e "$1/include/SDL" ]; then
    export SDL_PATH="${SDL_PATH-}${SDL_PATH:+ }$1/include/SDL"
    export SDL_LIB_PATH="${SDL_LIB_PATH-}${SDL_LIB_PATH:+ }-L$1/lib"
  fi
}

The last commit (f7fdc99) in the relevant PR #72812 changed the logic to:

addSDLPath () {
  if [ -e "$1/include/SDL" ]; then
    export SDL_PATH="${SDL_PATH-}${SDL_PATH:+ }$1/include/SDL"
  fi
  if [ -e "$1/lib" ]; then
    export SDL_LIB_PATH="${SDL_LIB_PATH-}${SDL_LIB_PATH:+ }-L$1/lib"
  fi
}

I was unable to find any justification for this change and the commit message looks suspicious: Merge commit 'afa48f16f265fd3e88073bca7929e1e103bd3dc3' into bash-no-undef-vars. The mentioned commit afa48f1 is not related to SDL so it seems like merge ought to have left SDL as is.

The way hook looks now, any package that has /lib gets added to SDL_LIB_PATH which is only used for SDL purposes within nixpkgs as far as I can tell. It seems that only SDL-related things should go there, like SDL_image, SDL_mixer, etc - basically the packages that have corresponding /include/SDL. Putting everything in there the way it works now is likely redundant.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.11 Release Notes (or backporting 23.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.

Copy link
Member

@FliegendeWurst FliegendeWurst left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Since this fix causes a lot of rebuilds, please rebase the PR onto staging (howto).

@FliegendeWurst FliegendeWurst added the 12. first-time contribution This PR is the author's first one; please be gentle! label Nov 3, 2023
@sergv sergv marked this pull request as draft November 3, 2023 22:54
@sergv sergv changed the base branch from master to staging November 3, 2023 22:56
@sergv sergv marked this pull request as ready for review November 3, 2023 23:24
@sergv
Copy link
Contributor Author

sergv commented Nov 3, 2023

Thanks for the review! I've rebased onto staging and changed merge target to staging as well.

Copy link
Member

@FliegendeWurst FliegendeWurst left a comment

Choose a reason for hiding this comment

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

Per https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#commit-conventions the first line of the commit message should be: "SDL: put only SDL-related paths in SDL_LIB_PATH" (or similar).
It's very good that you included some context in the commit description!

@sergv
Copy link
Contributor Author

sergv commented Nov 5, 2023

Renamed the commit and rebased on staging once more.

@FliegendeWurst FliegendeWurst added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Nov 5, 2023
Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I think that was just a sloppy merge "huh, conditioning -L on include path? that looks like I made a mistake."

Good sleuthing, and thanks for catching my mistake.

@Artturin
Copy link
Member

Artturin commented Nov 19, 2023

Probably won't work with a split dev though, I don't know a way around that.

@Ericson2314
Copy link
Member

Oh huh good catch

@sergv
Copy link
Contributor Author

sergv commented Nov 20, 2023

Good point about packages with split dev, I didn't give them a thought before. However I'm probably missing something yet it seems they won't cause a problem: the SDL's setup hook initializes SDL_PATH and SDL_LIB_PATH variables which within nixpkgs are only consumed by the SDL itself (only mentioned in SDL's find-headers.patch).

As far as I understood from mentions of the environment variables the hook is intended to make packages like SDL_image, SDL_mixer, SDL_ttf or SDL_gfx found by the SDL. None of these packages have split dev. Only SDL itself uses split dev but it doesn't need to add itself to the environment variables sine it's the consumer of those variables.

@Artturin
Copy link
Member

Artturin commented Nov 20, 2023

Add a comment that it's doesn't work with split dev because include and lib aren't in the same $1

@sergv
Copy link
Contributor Author

sergv commented Nov 22, 2023

I've added a note about split dev in the setup hook.

@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Mar 8, 2024
@Artturin
Copy link
Member

Artturin commented Mar 14, 2024

A bot seems to have merged this with extra commits...

@Artturin
Copy link
Member

image

@sergv Seems you rebased incorrectly and dropped your changes and github thought the pr was already merged :/ Can you make a new pr reconstructed from git reflog, I'll merge it.

Here's how you can rebase without dropping commits BTW https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#rebasing-between-branches-ie-from-master-to-staging

@sergv sergv mentioned this pull request Mar 14, 2024
13 tasks
@sergv
Copy link
Contributor Author

sergv commented Mar 14, 2024

@Artturin looks like I may have accidentally removed branch in my repo, but I'm not fully sure. I've created new PR at #296015.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.