Skip to content

csound: make bottle relocatable#75566

Closed
nwhetsell wants to merge 1 commit intoHomebrew:masterfrom
nwhetsell:csound-relocate
Closed

csound: make bottle relocatable#75566
nwhetsell wants to merge 1 commit intoHomebrew:masterfrom
nwhetsell:csound-relocate

Conversation

@nwhetsell
Copy link
Copy Markdown
Contributor

  • Have you followed the guidelines for contributing?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install <formula>)?

I think this makes Csound bottles relocatable on macOS.

Because Csound needs the RPATH to be @loader_path/../Frameworks, this PR does not use the rpath helper method introduced in Homebrew/brew#11187 (which returns @loader_path/../lib on macOS). One way to use the rpath helper method here would be to set the RPATH to—

rpath.sub(%r{/lib('?)$}, '/Frameworks\1')

—but, since the Csound formula requires macOS, this might be more trouble than it’s worth.

Related to #75458.

@BrewTestBot BrewTestBot added java Java use is a significant feature of the PR or issue no ARM bottle Formula has no ARM bottle labels Apr 20, 2021
@carlocab
Copy link
Copy Markdown
Member

We could make the rpath method take an argument that defaults to "lib". So you could do something like

-DCMAKE_INSTALL_RPATH=#{rpath("Frameworks")}

here.

@nwhetsell
Copy link
Copy Markdown
Contributor Author

We could make the rpath method take an argument that defaults to "lib".

Sounds good to me!

@carlocab
Copy link
Copy Markdown
Member

Let's wait for CI to finish here and see if the fix works first.

@nwhetsell
Copy link
Copy Markdown
Contributor Author

Well, the Big Sur failure is Csound seg faulting on exit:

https://github.com/Homebrew/homebrew-core/pull/75566/checks?check_run_id=2389982128#step:7:90

This is almost certainly an upstream issue (and possibly intermittent), but I don’t have a Big Sur machine to test this locally.

@carlocab
Copy link
Copy Markdown
Member

Doesn't make the bottles relocatable either, unfortunately. For the Catalina and Mojave bottles that were built:

❯ jq '.[].bottle.cellar' <*.bottle.json
"/usr/local/Cellar"
"/usr/local/Cellar"

@nwhetsell
Copy link
Copy Markdown
Contributor Author

OK, thanks.

How is the cellar property determined? Or, relatedly, do you know if there’s some way to use otool -l to see what’s causing this?

@carlocab
Copy link
Copy Markdown
Member

I think the idea is that brew uses install_name_tool to replace library ids and references to a placeholder, then uses strings to check for remaining HOMEBREW_CELLAR references in the binary files. You might get more insight into this from dev-cmd/bottle.rb, or by doing

brew install --build-bottle csound
brew bottle --verbose --debug csound

@nwhetsell
Copy link
Copy Markdown
Contributor Author

Thanks, that was a big help!

A lot of Csound’s functionality (opcodes, in Csound terms) are in dylibs that are built as part of Csound. Csound’s opcodes get installed in a subfolder of Csound’s Frameworks folder, but Csound also lets you load opcodes from any folder you wish. Because of this, Csound has a default directory from which it loads opcodes, and the default directory is wherever Csound’s built-in opcodes are installed. Unfortunately, this directory is an absolute path determined at compile-time.

In Csound’s CMakeLists.txt, a PLUGIN_INSTALL_DIR variable is set:

https://github.com/csound/csound/blob/6.15.0/CMakeLists.txt#L356-L361

This variable eventually gets turned into an absolute path and set as a CS_DEFAULT_PLUGINDIR preprocessor definition:

https://github.com/csound/csound/blob/6.15.0/CMakeLists.txt#L372-L378

And then CS_DEFAULT_PLUGINDIR gets baked into Csound:

https://github.com/csound/csound/blob/6.15.0/Top/csmodule.c#L446

Since CS_DEFAULT_PLUGINDIR starts with /usr/local/Cellar (usually), this prevents creating relocatable Csound bottles.

There doesn’t appear to be a good way to fix this, unfortunately. What I’ve done is edit Csound’s CMakeLists.txt to remove the offending directory (replacing it with .) and add a caveat saying how to make Csound find its own opcodes, but it’s totally understandable if doing something like this makes this PR un-merge-able.

@carlocab
Copy link
Copy Markdown
Member

Yes, I'm a little hesitant about making changes like this. For one thing, I suspect CS_DEFAULT_PLUGINDIR should actually point to a non-existent directory, rather than the current one (just in case it picks up things in the current directory that we don't want it to).

I think the correct move here would be to wait for Homebrew/brew#10846 to be implemented, as that should fix complete paths getting baked into binary artefacts.

@nwhetsell
Copy link
Copy Markdown
Contributor Author

I think the correct move here would be to wait for Homebrew/brew#10846 to be implemented, as that should fix complete paths getting baked into binary artefacts.

I agree.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label May 13, 2021
@github-actions github-actions bot closed this May 20, 2021
@github-actions github-actions bot added the outdated PR was locked due to age label Jun 20, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

java Java use is a significant feature of the PR or issue no ARM bottle Formula has no ARM bottle outdated PR was locked due to age stale No recent activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants