Skip to content

add macports libcxx dependency on older macs for gdb #27203

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

i3roly
Copy link

@i3roly i3roly commented Dec 25, 2024

this will ensure older systems are able to build and use the latest gdb with minimal effort

hopefully other members on the macports squad will look into the macro nusiance that otherwise impedes a clean compilation

Description

Type(s)
  • bugfix
  • enhancement
  • security fix
Tested on

macOS 10.7.5 11G63 x86_64
Xcode 4.2.1 4D502

Verification

Have you

  • followed our Commit Message Guidelines?
  • squashed and minimized your commits?
  • checked that there aren't other open pull requests for the same change?
  • referenced existing tickets on Trac with full URL in commit message?
  • checked your Portfile with port lint?
  • tried existing tests with sudo port test?
  • tried a full install with sudo port -vst install?
  • tested basic functionality of all binary files?
  • checked that the Portfile's most important variants haven't been broken?

this will ensure older systems are able to build and use the latest gdb
with minimal effort

hopefully other members on the macports squad will look into the macro
nusiance that otherwise impedes a clean compilation
Copy link
Contributor

@barracuda156 barracuda156 left a comment

Choose a reason for hiding this comment

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

This should be fixed.

@@ -86,6 +86,13 @@ pre-configure {

build.dir ${configure.dir}

#older macs require a new libcxx
if {${os.platform} eq "darwin" && ${os.major} < 15} {
configure.depends_lib-append port:macports-libcxx
Copy link
Contributor

Choose a reason for hiding this comment

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

This is wrong and gonna break builds on older OS. If you need this for libc++-consuming versions, please make it conditional accordingly.

@i3roly
Copy link
Author

i3roly commented Dec 26, 2024 via email

@barracuda156
Copy link
Contributor

@i3roly What you seem to want is to switch libc++-using systems to legacy-support-supplied libc++ (which is somewhat newer than archaic system one). However, this is not just unneeded but also breaking for systems which do not use libc++ to begin with. So the correct condition must include not only macOS version (whichever appropriate), but also C++ runtime, so that macports-libcxx is used only when C++ runtime is libc++.

@i3roly
Copy link
Author

i3roly commented Dec 26, 2024 via email

@barracuda156
Copy link
Contributor

i see what you’re saying. could you please provide the runtime check?

if {${os.platform} eq "darwin" && ${configure.cxx_stdlib} eq "libc++"} {

}

per what @barracuda156 stated, it's better to have a check for the
runtime since <=10.7 use libstdc++ as the default, where 10.7 was the
first move to using/including libc++.

this check will ensure older macs don't get rekt
#older macs require a new libcxx
if {${os.platform} eq "darwin" && ${os.major} < 15 && ${configure.cxx_stdlib} eq "libc++"} {
configure.depends_lib-append port:macports-libcxx
configure.cxxflags-append -L/opt/local/lib/libcxx

Choose a reason for hiding this comment

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

I don't get it why is hardcoded to /opt/local instead of ${prefix}.

@i3roly
Copy link
Author

i3roly commented Dec 27, 2024 via email

@i3roly
Copy link
Author

i3roly commented Dec 28, 2024

  1. I have never seen this construct used:

configure.depends_lib-append

does it do anything?

i didn't either, but apparently it's used a lot. it's supposed to ensure that macports-libcxx is installed prior to gdb for older macs. look here for more examples of depends_lib-append: https://github.com/search?q=repo%3Amacports%2Fmacports-ports+depends_lib-append&type=code

2. you are using:

configure.cxxflags-append -L${prefix}/lib/libcxx

appending linker flags to the cxxflags. They should be appended to the ldflags.

okay i can do that.

3. you are not setting any cxx include flags so the headers from the new libcxx are not being used.

gdb isn't complaining about the lack of headers. i think the newer clang headers are being used, it's just not able to find the appropriate (newer) libcxx associated with these headers, as i've pasted below.

4. the legacysupport PG has a mechanism to do all this correctly.  Although the code in the PG does have an error in it nobody has fixed yet, it works anyway in almost all cases and does all this correctly. Have you tried that?

# legacysupport.use_mp_libcxx: Use an update libcxx runtime from a recent macports clang build

yes, i have, but the problem is the libcxx isn't propagating towards the end of the build:

checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features by default... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with -std=gnu++17... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with -std=gnu++1z... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with -std=c++17... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with +std=c++17... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with -h std=c++17... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with -std:c++17... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with -std=c++1z... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with +std=c++1z... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with -h std=c++1z... no
checking whether /opt/local/bin/clang++-mp-17 supports C++17 features with -std:c++1z... no
configure: error: *** A compiler with support for C++17 language features is required.

so the root of the issue is that the macports-libcxx legacy portgroup macro isn't passing the library path so GDB's configure can detect it.

the purpose of depends_lib is to ensure that macports-libcxx is installed beforehand.

i don't think the legacy portgroup macro can enforce this? correct me if i'm wrong on that?

the headers are taken care of by the newer clang that has to be used.

i haven't tried with ldflags but i used your cxx-append as the catch-all since you have shown that it plumbs better, and i figured that it was the safest and best way. but i can try with ldflags too.

@i3roly
Copy link
Author

i3roly commented Dec 28, 2024 via email

remove configure. from depends_lib-append
change cxxflags to ldflags
@i3roly
Copy link
Author

i3roly commented Dec 28, 2024

so what would you recommend in this particular instance?

adding a line like the following?

configure.cppflags-append -I${prefix}/libcxx

@i3roly
Copy link
Author

i3roly commented Dec 28, 2024

fwiw i noticed that even on sierra (10.12) with the bundled clang 9/xcode, that gdb also fails to build due to the c++17 stuff.

very surprised by this, but seems like the version check needs to be < 17 !

pretty interesting that no one has picked this up? hope i'm wrong, but
default clt failed to install gdb.
@i3roly
Copy link
Author

i3roly commented Jan 3, 2025

anybody? it's getting tiresome having to edit portfiles on vms.

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

Successfully merging this pull request may close these issues.

4 participants