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

Fail to build on MacOS #143

Open
haozheji opened this issue Feb 22, 2023 · 10 comments
Open

Fail to build on MacOS #143

haozheji opened this issue Feb 22, 2023 · 10 comments

Comments

@haozheji
Copy link

Hi! I got this error caused by clatexmath package when building on macos:

Last 15 lines from /Users/haozhe/Library/Logs/Homebrew/clatexmath/02.ninja:

/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include/c++/v1/__functional/not_fn.h:38:36: note: candidate template ignored: substitution failure [with _Fn = int (int)]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>'
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f)
                                   ^
In file included from ../src/atom/atom_matrix.cpp:3:
In file included from ../src/atom/atom_impl.h:4:
In file included from ../src/common.h:31:
../src/utils/string_utils.h:92:46: error: no matching function for call to 'not_fn'
  s.erase(std::find_if(s.rbegin(), s.rend(), std::not_fn<int(int)>(isspace)).base(), s.end());
                                             ^~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include/c++/v1/__functional/not_fn.h:38:36: note: candidate template ignored: substitution failure [with _Fn = int (int)]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>'
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f)
                                   ^
2 errors generated.
ninja: build stopped: subcommand failed.

How can I fix this? Thanks!

@haozheji
Copy link
Author

I reinstall clatexmath, and the full log is here: (still with the same error it seems)

==> Downloading https://formulae.brew.sh/api/formula.json
######################################################################## 100.0%
==> Fetching dependencies for sp1ritcs/tap/notekit: sp1ritCS/tap/clatexmath and zlib
==> Fetching sp1ritcs/tap/clatexmath
==> Cloning https://github.com/NanoMichael/cLaTeXMath.git
Cloning into '/Users/haozhe/Library/Caches/Homebrew/clatexmath--git'...
==> Checking out revision 3603a3c265a77c3ec64df3631cc9a5c90508ddd5
HEAD is now at 3603a3c Add support for C++20.
==> Fetching zlib
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/manifests/1.2.13
Already downloaded: /Users/haozhe/Library/Caches/Homebrew/downloads/fdccac006bc82ad87194cffa03a899a1a5225cffe5b052b27a5fe2dc8540ee03--zlib-1.2.13.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/blobs/sha256:8473a260917ec
Already downloaded: /Users/haozhe/Library/Caches/Homebrew/downloads/5a16f3c5417c48892896066c81fbef465eb91cf615eb9fa040a68c8ba1824dca--zlib--1.2.13.monterey.bottle.tar.gz
==> Fetching sp1ritcs/tap/notekit
==> Cloning https://github.com/blackhole89/notekit.git
Updating /Users/haozhe/Library/Caches/Homebrew/notekit--patch--git
origin/HEAD set to master
refs/remotes/origin/master
==> Checking out revision 9ca343033c208f942152cde1c4f6747f7cdd2850
HEAD is now at 9ca3430 Fix macos build (#121)
HEAD is now at 9ca3430 Fix macos build (#121)
==> Cloning https://github.com/blackhole89/notekit.git
Updating /Users/haozhe/Library/Caches/Homebrew/notekit--git
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
HEAD is now at fd59af9 Recalculate colors whenever the theme changes. Fixes #132.
==> Installing notekit from sp1ritcs/tap
==> Installing dependencies for sp1ritcs/tap/notekit: sp1ritCS/tap/clatexmath and zlib
==> Installing sp1ritcs/tap/notekit dependency: sp1ritCS/tap/clatexmath
==> meson --prefix=/usr/local/Cellar/clatexmath/0.0.4 --libdir=/usr/local/Cellar
==> ninja -v
Last 15 lines from /Users/haozhe/Library/Logs/Homebrew/clatexmath/02.ninja:
                                                      ^~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include/c++/v1/__functional/not_fn.h:38:36: note: candidate template ignored: substitution failure [with _Fn = int (int)]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>'
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f)
                                   ^
In file included from ../src/atom/atom_matrix.cpp:3:
In file included from ../src/atom/atom_impl.h:4:
In file included from ../src/common.h:31:
../src/utils/string_utils.h:92:46: error: no matching function for call to 'not_fn'
  s.erase(std::find_if(s.rbegin(), s.rend(), std::not_fn<int(int)>(isspace)).base(), s.end());
                                             ^~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include/c++/v1/__functional/not_fn.h:38:36: note: candidate template ignored: substitution failure [with _Fn = int (int)]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>'
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f)
                                   ^
2 errors generated.
ninja: build stopped: subcommand failed.

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/sp1ritcs/homebrew-tap/issues

@sp1ritCS
Copy link
Contributor

Can you send me the whole log? (apparently brew gist-logs clatexmath should automatically upload it to github and giveyou a link)

I'd assume the problem is, that meson is probably picking a wrong compiler / compiler version and doesn't have that std::not_fn symbol.

@AndreKoepke
Copy link

@sp1ritCS I have the same problem. Here are the logs: https://gist.github.com/AndreKoepke/da1b67c33c229a1c6c23f5ac13027641

@sp1ritCS
Copy link
Contributor

Thanks. I'm currently don't have access to my computer that has the OSX VM I've been testing against (however the VM also runs an outdated version of OSX, so things might have changed anyway).

I'm not able to reproduce the issue on linux with clang++, so apple must have changed something.

Are you able to compile the following piece of code?

#include <string>
#include <iostream>
#include <ostream>
#include <functional>
#include <algorithm>

#if (__cplusplus >= 201703L) || (defined(_MSC_VER) && defined(_HAS_CXX17) && _HAS_CXX17)
#define CLATEX_CXX17 1
#else
#define CLATEX_CXX17 0
#endif

inline std::string& ltrim(std::string& s) {
#if CLATEX_CXX17
  s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not_fn<int(int)>(isspace)));
#else
  s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::cref<int(int)>(isspace))));
#endif
  return s;
}


int main(void) {
	std::string body = "  padded string";
	std::cout << ltrim(body) << std::endl;
}

using the each of the following commands

clang++ <filename>.cpp
clang++ -std=c++14 <filename>.cpp
clang++ -std=c++17 <filename>.cpp
clang++ -std=c++20 <filename>.cpp

and tell me which ones work and which ones fail?

@sp1ritCS
Copy link
Contributor

I've wrote a patch (https://gist.github.com/sp1ritCS/14c0cc891918d58e1af00622f64ee08a) that should fix these issues for now. You might be able to reinstall notekit now (not quite sure).

I'm really unhappy with homebrew rn, maybe moving to macports (or simply static linking notekit together) might be a better option.

@AndreKoepke
Copy link

AndreKoepke commented Mar 30, 2023

Thanks for your effort. :)

clang++ <filename>.cpp
clang++ -std=c++14 <filename>.cpp
clang++ -std=c++17 <filename>.cpp
clang++ -std=c++20 <filename>.cpp

and tell me which ones work and which ones fail?

c++17 and c++20 fails.

How can I tryout the fix? I only used brew install --HEAD sp1ritCS/tap/notekit before.

@sp1ritCS
Copy link
Contributor

sp1ritCS commented Mar 30, 2023

c++17 and c++20 fails.

I presume with the same reason cLaTeXMath fails?

How can I tryout the fix? I only used brew install --HEAD sp1ritCS/tap/notekit before.

you probably just want to rerun the same command, given that it has been unable to install it previously. If that doesn't work try installing clatexmath (from HEAD) first (brew install --HEAD sp1ritCS/tap/clatexmath) and then run the install notekit command.

EDIT: I don't quite know if homebrew will fetch the latest revision of my tap automatically, you might have to do this manualy.

I'm not quite sure of the location, but try running git fetch origin and git reset --hard a087deeb2b0a279c2b0798a989c699aa40d55d01
in /usr/local/Homebrew/Library/Taps/sp1ritCS/homebrew-tap/.

@AndreKoepke
Copy link

I presume with the same reason cLaTeXMath fails?

/tmp [ clang++ -std=c++20 test.cpp
test.cpp:7:75: error: expected ')' in preprocessor expression
#if (__cplusplus >= 201703L) || (defined(_MSC_VER) && defined(_HAS_CXX17) 
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
test.cpp:7:33: note: to match this '('
#if (__cplusplus >= 201703L) || (defined(_MSC_VER) && defined(_HAS_CXX17) 
                                ^
test.cpp:20:6: error: no member named 'not1' in namespace 'std'
std::not1(std::cref<int(int)>(isspace))));
~~~~~^
2 errors generated.

Installing notekit neither clatexmath doesn't work. With clatexmath, I got this:

/tmp [ brew install --HEAD sp1ritCS/tap/clatexmath                                                                              ] 5:59 PM
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################## 100.0%
==> Fetching sp1ritcs/tap/clatexmath
==> Cloning https://github.com/NanoMichael/cLaTeXMath.git
Updating /Users/akop/Library/Caches/Homebrew/clatexmath--git
==> Checking out branch master
Previous HEAD position was 3603a3c Add support for C++20.
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
HEAD is now at e3199b8 fix MSVC build
==> Installing clatexmath from sp1ritcs/tap
==> meson --prefix=/opt/homebrew/Cellar/clatexmath/HEAD-e3199b8 --libdir=/opt/homebrew/Cellar/clatexmath/HEAD-e3199b8/lib --buildtype=rele
==> ninja -v
Last 15 lines from /Users/akop/Library/Logs/Homebrew/clatexmath/02.ninja:
                                                      ^~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/c++/v1/__functional/not_fn.h:38:36: note: candidate template ignored: substitution failure [with _Fn = int (int)]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>'
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f)
                                   ^
In file included from ../src/atom/atom_impl.cpp:1:
In file included from ../src/atom/atom_impl.h:4:
In file included from ../src/common.h:31:
../src/utils/string_utils.h:92:46: error: no matching function for call to 'not_fn'
  s.erase(std::find_if(s.rbegin(), s.rend(), std::not_fn<int(int)>(isspace)).base(), s.end());
                                             ^~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/c++/v1/__functional/not_fn.h:38:36: note: candidate template ignored: substitution failure [with _Fn = int (int)]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>'
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f)
                                   ^
2 errors generated.
ninja: build stopped: subcommand failed.

The path is /opt/homebrew/Library/Taps/sp1ritcs/homebrew-tap.
I manually run git pull and after that the installation was successful. 😎

@sp1ritCS
Copy link
Contributor

The path is /opt/homebrew/Library/Taps/sp1ritcs/homebrew-tap.
I manually run git pull and after that the installation was successful. 😎

great to hear

the generated error is really wierd tho. Almost like the preprocessor lexer failing or something 🤷🏻‍♂️ . I wouldn't know what the issue might be here.

@barracuda156
Copy link

Fails differently now: #158

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

No branches or pull requests

4 participants