255 Commits

Author SHA1 Message Date
Carlo Cabrera
478e42d536
linux/linkage_checker: remove gcc from undeclared_deps 2022-08-10 19:04:35 +08:00
Carlo Cabrera
fa26b5a06d
linux/super: add unversioned GCC lib directory to RPATH
This adds GCC's runtime lib directory to the RPATH of every build on
Linux (unconditionally!).

This is useful for three things:

1. It fixes versioned GCC linkage for formulae that users build from
   source instead of pouring from a bottle. We currently only handle
   bottle installs. See #13633.

2. It helps minimise the GCC dependency explosion. When a formula has a
   Linux-only GCC dependency, then all its dependents that link with
   some GCC runtime library (typically `libstdc++`) must, before this
   change, also adopt a GCC dependency. This is a consequence of our
   injecting GCC's runtime library directory into RPATH only when a
   formula is built with GCC (this is done through the specs file). We
   can avoid the need to do this by always injecting this path instead.

3. This enables us to automatically install Homebrew GCC whenever the
   user's GCC is too old and the formula may need it. Without this
   change, auto-installing GCC is not that useful because formulae that
   need it may not know to look for our GCC, unless the formula already
   happened to be built with our GCC. With this change, these formulae
   will always be able to find our GCC when it is installed. This is
   particularly useful for when we start building with a version of GCC
   that is much closer to the latest than we currently do.

This approach comes with at least two drawbacks:

1. We will see spurious linkage warnings in CI about an undeclared
   dependency with linkage as soon as Homebrew GCC is installed, because
   formulae will link with our GCC instead of the host's. Users will
   also see a similar complaint if they do `brew linkage`.

2. This leans _very_ heavily on GCC delivering backward compatibility of
   their runtime libraries. If they do not, we could see different
   behaviour across different CI runs for the same formula depending on
   whether Homebrew GCC is installed.

It's worth noting that item 3 in the "useful" list above may rely on
features not yet implement in `brew`.
2022-08-06 13:21:18 +08:00
Carlo Cabrera
2d95b9acda
linux/keg_relocate: remove patchelf exemption
I don't think this is needed anymore. We probably needed this when we
used `patchelf` to do `RPATH` rewriting, but this is no longer the case.
2022-08-06 00:26:48 +08:00
Rylan Polster
d4ddfb88df
Merge pull request #13616 from Rylan12/simulate-macos-on-linux
Move `HOMEBREW_SIMULATE_MACOS_ON_LINUX` handling to `SimulateSystem`
2022-08-05 10:23:13 -04:00
Carlo Cabrera
fec5b4080a
linux/diagnostic: add check for versioned GCC linkage
This complements my other two GCC-on-Linux PRs (#13631, #13633), however
they are both reliant on bottles eventually being (re-)poured.

Let's try to speed that up by returning an error message from `brew doctor`
whenever a user has formulae installed that would benefit from a `brew reinstall`.
2022-08-03 20:54:16 +08:00
Carlo Cabrera
1c0eac7874
Exclude GCC formulae from RPATH modification for GCC 2022-08-02 19:09:38 +08:00
Carlo Cabrera
532460c098
keg_relocate: fix new GCC lib directory
Also add comment explaining what this line does, along with a TODO
suggesting a replacement once we've shipped the GCC PR.
2022-08-02 13:29:14 +08:00
Carlo Cabrera
53fdb64113
keg_relocate (linux): prepend gcc/lib/current to RPATH when needed
This should help keep bottles that require GCC working when
Homebrew/homebrew-core#106755 is merged.

This only works on freshly-poured bottles. Previously installed bottles
will still break on systems with a host GCC older than GCC 11.
2022-08-02 11:02:47 +08:00
Lukas Oberhuber
cd9fe97c55 Improve style 2022-07-30 11:10:26 +01:00
Rylan Polster
ea1f2098ac
Move HOMEBREW_SIMULATE_MACOS_ON_LINUX handling to SimulateSystem 2022-07-28 15:04:25 -04:00
Lukas Oberhuber
215e545660 brew style 2022-07-26 19:28:30 +01:00
Lukas Oberhuber
c2a95f077f Compiler -g flag set based on --debug-symbols 2022-07-26 17:18:01 +01:00
Rylan Polster
34a1bc6618
Use SimulateSystem for ignore_missing_libraries 2022-07-23 03:09:29 +02:00
danielnachun
47b6492098
extend/os/linux/extend/ENV/super.rb: add homebrew_extra_include_paths 2022-07-17 17:15:06 -07:00
Bo Anderson
01d1f1ecb6
Fix Keg.bottle_dependencies including unneeded build dependencies 2022-06-30 04:11:15 +01:00
Bo Anderson
2ddce84225
Remove Keg.relocation_formulae
We no longer use any formulae for relocation.
2022-06-30 03:39:29 +01:00
Rylan Polster
b538ce7361
Add OnSystem module to generate on_* methods for formulae and casks 2022-06-24 14:37:50 -04:00
Rylan Polster
cff0122fc4
Remove unnecessary HOMEBREW_INSTALL_FROM_API checks 2022-06-15 16:35:50 -04:00
Michael Cho
b6905fe0f9
superenv: prioritize dependencies' opt_lib in Linux rpath 2022-05-03 23:14:30 -07:00
Bo Anderson
e6cb1f18e7
Merge pull request #13151 from Bo98/libcrypt-1-deprecation
linkage_checker: deprecate linkage to libcrypt.so.1
2022-04-27 16:00:22 +01:00
Bo Anderson
6db3ee6b0a
extend/os/linux/keg_relocate: restore checking only GCC major versions 2022-04-22 01:41:23 +01:00
Bo Anderson
5d28c5166b
linkage_checker: deprecate linkage to libcrypt.so.1 2022-04-18 16:42:08 +01:00
xxyzz
990b61250a
Get gcc version from API to avoid downloading gcc bottles on Linux 2022-03-30 20:37:19 +08:00
Caleb Xu
d9780bd260
diagnostic: skip linuxbrew-core tap check when installing from API 2022-03-28 14:59:32 -04:00
Mike McQuaid
cf0468c88f
Merge pull request #12661 from sjackman/sj/relocate_dynamic_linkage
Patch neither glibc nor glibc@* using patchelf
2022-01-03 13:08:42 +00:00
Shaun Jackman
06bf91fe0b
Use formula_optionally_versioned_regex
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2022-01-02 17:30:34 -08:00
Shaun Jackman
2ad3f0a089 Patch neither glibc nor glibc@* using patchelf
Patching the dynamic linker of glibc breaks it.
2022-01-02 13:44:13 -08:00
Shaun Jackman
4e68a7b5bc Allow linkage to libnss_files.so.2 on Linux
libnss_nis.so.2 in glibc@2.13 has linkage to libnss_files.so.2.
2021-12-31 16:17:36 -08:00
Douglas Eichelberger
65f1766497 Remove unknown YARD tags 2021-11-30 08:01:20 -08:00
Mike McQuaid
0118e6ec41
Apply suggestions from code review
Co-authored-by: Xuehai Pan <XuehaiPan@outlook.com>
2021-10-21 15:10:17 +01:00
Mike McQuaid
eb1b244fd2
update-report: better handle user set bottle domain, core git remote.
Unset these variables and print a warning if they were set to
non-default values.
2021-10-21 15:01:58 +01:00
Michka Popoff
1cc7ca33c0
update: migrate everyone from linuxbrew-core to homebrew-core
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-10-20 11:01:38 +01:00
Mike McQuaid
0cda6a0657
Only use patchelf.rb
Remove support for using the `patchelf` formula for writing as it's been
off by default for a long time now.
2021-10-19 15:15:56 +01:00
Michka Popoff
e8ee5b05f9
Migrate linuxbrew-core to homebrew-core on update.
- Only for HOMEBREW_DEVELOPER
- Except for HOMEBREW_CORE_MERGE_MAINTAINER
- Except for GitHub Actions CI

Co-authored-by: Rylan Polster <rslpolster@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-10-11 21:04:58 +02:00
fn ⌃ ⌥
9638e3e8c0 development_tools: update type signatures 2021-09-29 17:44:26 -07:00
fn ⌃ ⌥
61a7ffb999 development_tools: add type signatures 2021-09-29 15:12:53 -07:00
Bo Anderson
b55498269f
Revamp APIs around bottle specifications 2021-09-20 15:02:05 +01:00
Carlo Cabrera
22db7aa516
superenv: set M4 on Linux when bison is a dependency
Bison no longer remembers the path to `m4` as of
Homebrew/homebrew-core#84931. Since superenv does not put runtime
dependencies of build dependences in `PATH`, we now need to help Bison
find `m4` by setting `M4` in the environment.

See also Homebrew/homebrew-core#85260.
2021-09-16 21:11:12 +08:00
Bo Anderson
861dea9ada
Bump various type strictnesses 2021-09-11 01:00:23 +01:00
Mike McQuaid
2b6e580636
ENV/super: add shims_path helper method.
This allows us to stop repeatedly hardcoding this on macOS/Linux in
formulae.
2021-09-08 12:35:36 +01:00
Michka Popoff
4ef058412c
brew.sh: set HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX when core repo is homebrew-core
See https://github.com/Homebrew/install/pull/571

When the install script sets as https://github.com/Homebrew/homebrew-core,
we need to use the homebrew-core bottle domain, and correctly set
the HOMEBREW_CORE_DEFAULT_GIT_REMOTE below.

This also fixes the brew doctor issue for new homebrew-core Linux installations

Warning: Suspicious https://github.com/Homebrew/linuxbrew-core git origin remote found.
The current git origin is:
  https://github.com/Homebrew/homebrew-core

With a non-standard origin, Homebrew won't update properly.
You can solve this by setting the origin remote:
  git -C "/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core" remote set-url origin https://github.com/Homebrew/linuxbrew-core
2021-08-31 21:48:38 +02:00
Carlo Cabrera
0ae032ad2f
Merge pull request #11756 from carlocab/deuniversalize-machos
formula: add `deuniversalize_machos` method
2021-08-18 02:28:34 +08:00
Rylan Polster
f84265f9a2
Remove extra type signatures 2021-08-06 04:40:22 -04:00
Rylan Polster
737dd1654b
Refactor API methods 2021-08-06 04:31:27 -04:00
Carlo Cabrera
5e0b786da2
formula: add deuniversalize_machos method
This method takes an optional array of `Pathnames`s or `Strings`s and
extracts the native slice from the specified universal binary. If no
parameter is supplied, this is done on all compatible universal binaries
in a formula's keg.

`deuniversalize_machos` is a no-op on Linux.

I still need to look into a) error handling, and b) whether using this
method requires codesigning on ARM.

I've also added signatures to the methods in `extend/os/linux/formula`.
2021-07-22 01:24:56 +08:00
Dawid Dziurla
8d5dc50b68
keg_relocate: swap env var 2021-07-04 15:02:39 +02:00
danielnachun
dc8568f541 linkage_checker: add libatomic 2021-05-31 00:40:19 -07:00
Bo Anderson
ae49b06600
keg_relocate: replace Perl shebangs 2021-05-10 06:13:54 +01:00
Carlo Cabrera
309504a32c
formula: add rpath helper method
About 40 formulae set `CMAKE_INSTALL_RPATH` to `lib` or `opt_lib`, but
this breaks bottle relocatability.

The correct solution is to use `@loader_path/../lib`, but this is macOS
specific, so it requires some OS-specific logic. Rather than replicating
this logic over many formulae, we may as well define a helper method for
it.

See https://github.com/Homebrew/homebrew-core/issues/75458.
2021-04-19 09:23:33 +01:00
Mike McQuaid
d73351251c
Deprecate, disable, delete code for next major/minor version.
Do the usual dance for bumping our major/minor version.
2021-04-09 09:30:36 +01:00