GithubHelp home page GithubHelp logo

Comments (8)

ZhongRuoyu avatar ZhongRuoyu commented on July 4, 2024 4

I believe this is llvm/llvm-project#77653 (and llvm/llvm-project#84392). As a workaround, try adding the flag -L"$(brew --prefix llvm)"/lib/c++.

from homebrew-core.

talkeren avatar talkeren commented on July 4, 2024 1

My use case is using clang to distribute a standalone binary for mac, so I want that it will be linked against the system libc.
If anyone else is interested, this was my workaround hack for this issue: (warning: it is permentatly modifying the libc++ headers, I am just using it in a github action)

sed -i '' '/^#define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS/d' "$(brew --prefix llvm)"/include/c++/v1/__config_site

after that I could target the minimum version MacOS version that is required for std::println:
echo "CXXFLAGS=-mmacos-version-min=13.3" >> $GITHUB_ENV

from homebrew-core.

gen740 avatar gen740 commented on July 4, 2024

As a workaround, try adding the flag -L"$(brew --prefix llvm)"/lib/c++.

It works for me. Thanks!

from homebrew-core.

talkeren avatar talkeren commented on July 4, 2024

Hey, I have encountered the same issue and looked into the issue. Yes linking against the bundled libc++ solves it, but it seems that libc++ for macos does support <print> with the native lib, the this is how it was implemented:
llvm/llvm-project@4a87db6
_LIBCPP_AVAILABILITY_HAS_PRINT has to be set to zero so it will just skip using the linked functions and loss a small functionality.
And they set it only with the vendor availability annotations for apple:
https://github.com/llvm/llvm-project/blob/80f510bbc9561324fc13bac22aad2e3ef47a59c5/libcxx/cmake/caches/Apple.cmake#L9
In the libc++ includes in homebrew _LIBCPP_AVAILABILITY_HAS_PRINT is 1, so this feature is only available when linking against the bundled libc++.

from homebrew-core.

Bo98 avatar Bo98 commented on July 4, 2024

I guess ultimately the problem is the wrong C++ headers being used. If you're linking with system libc++ then it should be using the C++ headers shipped with the macOS SDK.

Currently there isn't an easy way to tell clang to switch between libc++ installs, unless you mess around with -nostdinc++.

Maybe splitting libc++ into a separate formula might be a starting point here.

from homebrew-core.

talkeren avatar talkeren commented on July 4, 2024

If you're linking with system libc++ then it should be using the C++ headers shipped with the macOS SDK.

clang and libc++ has the feature to target specific versions of macos (with the availability annotation), so in this situation I still wish that I could use the newest libc++ with that capability and not be stuck with the slowly updating macos sdks. Maybe a different formula for libc++ with LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS could be great.

from homebrew-core.

HerrCai0907 avatar HerrCai0907 commented on July 4, 2024

The bug reason is clang use header files which are installed by brew but use the libc++ in sysroot.
So another workaround is remove the header files in folder of homebrew.

mv /opt/homebrew/Cellar/llvm/18.1.5/include/c++/v1 /opt/homebrew/Cellar/llvm/18.1.5/include/c++/v1.bak

from homebrew-core.

github-actions avatar github-actions commented on July 4, 2024

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

from homebrew-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.