NNPDF / pineappl

PineAPPL is not an extension of APPLgrid
https://nnpdf.github.io/pineappl/
GNU General Public License v3.0
12 stars 3 forks source link

Cargo build fails in Mac M1 #252

Closed andreab1997 closed 3 months ago

andreab1997 commented 6 months ago

Trying to install pineappl_cli on a Mac M1 with cargo install --locked pineappl_cli I get the following error log

Updating crates.io index
  Installing pineappl_cli v0.6.3
    Updating crates.io index
    Updating crates.io index
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.6
   Compiling quote v1.0.26
   Compiling libc v0.2.140
   Compiling autocfg v1.1.0
   Compiling syn v1.0.107
   Compiling cfg-if v1.0.0
   Compiling cc v1.0.78
   Compiling io-lifetimes v1.0.3
   Compiling crossbeam-utils v0.8.14
   Compiling num-traits v0.2.15
   Compiling rustix v0.37.4
   Compiling bitflags v1.3.2
   Compiling link-cplusplus v1.0.8
   Compiling memoffset v0.7.1
   Compiling once_cell v1.16.0
   Compiling serde_derive v1.0.152
   Compiling scratch v1.0.3
   Compiling errno v0.3.0
   Compiling crossbeam-epoch v0.9.13
   Compiling proc-macro-hack v0.5.20+deprecated
   Compiling cxxbridge-flags v1.0.85
   Compiling unicode-width v0.1.10
   Compiling termcolor v1.1.3
   Compiling serde v1.0.152
   Compiling codespan-reporting v0.11.1
   Compiling is-terminal v0.4.6
   Compiling cxx v1.0.85
   Compiling num-integer v0.1.45
   Compiling lazy_static v1.4.0
   Compiling utf8parse v0.2.1
   Compiling thiserror v1.0.38
   Compiling scopeguard v1.1.0
   Compiling anstyle-parse v0.1.1
   Compiling terminal_size v0.1.17
   Compiling dirs-sys-next v0.1.2
   Compiling pkg-config v0.3.26
   Compiling anstyle v0.3.5
   Compiling concolor-override v1.0.0
   Compiling concolor-query v0.3.3
   Compiling rayon-core v1.10.1
   Compiling regex-syntax v0.6.28
   Compiling static_assertions v1.1.0
   Compiling either v1.8.0
   Compiling rawpointer v0.2.1
   Compiling matrixmultiply v0.3.2
   Compiling twox-hash v1.6.3
The following warnings were emitted during compilation:

warning: In file included from src/cxx.cc:1:
warning: src/../include/cxx.h:24:1: warning: inline namespaces are a C++11 feature [-Wc++11-inline-namespace]
warning: inline namespace cxxbridge1 {
warning: ^
warning: src/../include/cxx.h:36:14: warning: 'final' keyword is a C++11 extension [-Wc++11-extensions]
warning: class String final {
warning:              ^
warning: src/../include/cxx.h:38:11: error: expected ';' at end of declaration list
warning:   String() noexcept;
warning:           ^
warning:           ;
warning: src/../include/cxx.h:39:25: error: expected ';' at end of declaration list
warning:   String(const String &) noexcept;
warning:                         ^
warning:                         ;
warning: src/../include/cxx.h:40:17: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
warning:   String(String &&) noexcept;
warning:                 ^
warning: src/../include/cxx.h:40:20: error: expected ';' at end of declaration list
warning:   String(String &&) noexcept;
warning:                    ^
warning:                    ;
warning: src/../include/cxx.h:41:12: error: expected ';' at end of declaration list
warning:   ~String() noexcept;
warning:            ^
warning:            ;
warning: src/../include/cxx.h:50:43: error: expected ';' at end of declaration list
warning:   static String lossy(const std::string &) noexcept;
warning:                                           ^
warning:                                           ;
warning: src/../include/cxx.h:51:36: error: expected ';' at end of declaration list
warning:   static String lossy(const char *) noexcept;
warning:                                    ^
warning:                                    ;
warning: src/../include/cxx.h:52:49: error: expected ';' at end of declaration list
warning:   static String lossy(const char *, std::size_t) noexcept;
warning:                                                 ^
warning:                                                 ;
warning: src/../include/cxx.h:53:40: error: expected ';' at end of declaration list
warning:   static String lossy(const char16_t *) noexcept;
warning:                                        ^
warning:                                        ;
warning: src/../include/cxx.h:54:53: error: expected ';' at end of declaration list
warning:   static String lossy(const char16_t *, std::size_t) noexcept;
warning:                                                     ^
warning:                                                     ;
warning: src/../include/cxx.h:56:37: warning: reference qualifiers on functions are a C++11 extension [-Wc++11-extensions]
warning:   String &operator=(const String &) &noexcept;
warning:                                     ^
warning: src/../include/cxx.h:56:38: error: expected ';' at end of declaration list
warning:   String &operator=(const String &) &noexcept;
warning:                                      ^
warning:                                      ;
warning: src/../include/cxx.h:57:28: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
warning:   String &operator=(String &&) &noexcept;
warning:                            ^
warning: src/../include/cxx.h:57:32: warning: reference qualifiers on functions are a C++11 extension [-Wc++11-extensions]
warning:   String &operator=(String &&) &noexcept;
warning:                                ^
warning: src/../include/cxx.h:57:33: error: expected ';' at end of declaration list
warning:   String &operator=(String &&) &noexcept;
warning:                                 ^
warning:                                 ;
warning: src/../include/cxx.h:59:3: warning: explicit conversion functions are a C++11 extension [-Wc++11-extensions]
warning:   explicit operator std::string() const;
warning:   ^~~~~~~~
warning: src/../include/cxx.h:62:27: error: expected ';' at end of declaration list
warning:   const char *data() const noexcept;
warning:                           ^
warning:                           ;
warning: src/../include/cxx.h:63:27: error: expected ';' at end of declaration list
warning:   std::size_t size() const noexcept;
warning:                           ^
warning:                           ;
warning: src/../include/cxx.h:64:29: error: expected ';' at end of declaration list
warning:   std::size_t length() const noexcept;
warning:                             ^
warning:                             ;
warning: src/../include/cxx.h:65:21: error: expected ';' at end of declaration list
warning:   bool empty() const noexcept;
warning:                     ^
warning:                     ;
warning: src/../include/cxx.h:67:22: error: expected ';' at end of declaration list
warning:   const char *c_str() noexcept;
warning:                      ^
warning:                      ;
warning: src/../include/cxx.h:69:31: error: expected ';' at end of declaration list
warning:   std::size_t capacity() const noexcept;
warning:                               ^
warning:                               ;
warning: src/../include/cxx.h:70:31: error: expected ';' at end of declaration list
warning:   void reserve(size_t new_cap) noexcept;
warning:                               ^
warning:                               ;
warning: src/../include/cxx.h:72:20: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
warning:   using iterator = char *;
warning:                    ^
warning: src/../include/cxx.h:73:19: error: expected ';' at end of declaration list
warning:   iterator begin() noexcept;
warning:                   ^
warning:                   ;
warning: fatal error: too many errors emitted, stopping now [-ferror-limit=]
warning: 8 warnings and 20 errors generated.

error: failed to run custom build command for `cxx v1.0.85`

Caused by:
  process didn't exit successfully: `/var/folders/25/4w83mpb16zv6m8pxz9w5b1qm0000gn/T/cargo-installCICpWT/release/build/cxx-06c172a533ae732e/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("aarch64-apple-darwin")
  OPT_LEVEL = Some("3")
  HOST = Some("aarch64-apple-darwin")
  cargo:rerun-if-env-changed=CXX_aarch64-apple-darwin
  CXX_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CXX_aarch64_apple_darwin
  CXX_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-apple-darwin
  CXXFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_apple_darwin
  CXXFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,vh")
  cargo:rerun-if-env-changed=CXX_aarch64-apple-darwin
  CXX_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CXX_aarch64_apple_darwin
  CXX_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-apple-darwin
  CXXFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_apple_darwin
  CXXFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,vh")
  running: env -u IPHONEOS_DEPLOYMENT_TARGET "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-Wall" "-Wextra" "-o" "/var/folders/25/4w83mpb16zv6m8pxz9w5b1qm0000gn/T/cargo-installCICpWT/release/build/cxx-ec000d7171a5aab8/out/src/cxx.o" "-c" "src/cxx.cc"
  cargo:warning=In file included from src/cxx.cc:1:
  cargo:warning=src/../include/cxx.h:24:1: warning: inline namespaces are a C++11 feature [-Wc++11-inline-namespace]
  cargo:warning=inline namespace cxxbridge1 {
  cargo:warning=^
  cargo:warning=src/../include/cxx.h:36:14: warning: 'final' keyword is a C++11 extension [-Wc++11-extensions]
  cargo:warning=class String final {
  cargo:warning=             ^
  cargo:warning=src/../include/cxx.h:38:11: error: expected ';' at end of declaration list
  cargo:warning=  String() noexcept;
  cargo:warning=          ^
  cargo:warning=          ;
  cargo:warning=src/../include/cxx.h:39:25: error: expected ';' at end of declaration list
  cargo:warning=  String(const String &) noexcept;
  cargo:warning=                        ^
  cargo:warning=                        ;
  cargo:warning=src/../include/cxx.h:40:17: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  cargo:warning=  String(String &&) noexcept;
  cargo:warning=                ^
  cargo:warning=src/../include/cxx.h:40:20: error: expected ';' at end of declaration list
  cargo:warning=  String(String &&) noexcept;
  cargo:warning=                   ^
  cargo:warning=                   ;
  cargo:warning=src/../include/cxx.h:41:12: error: expected ';' at end of declaration list
  cargo:warning=  ~String() noexcept;
  cargo:warning=           ^
  cargo:warning=           ;
  cargo:warning=src/../include/cxx.h:50:43: error: expected ';' at end of declaration list
  cargo:warning=  static String lossy(const std::string &) noexcept;
  cargo:warning=                                          ^
  cargo:warning=                                          ;
  cargo:warning=src/../include/cxx.h:51:36: error: expected ';' at end of declaration list
  cargo:warning=  static String lossy(const char *) noexcept;
  cargo:warning=                                   ^
  cargo:warning=                                   ;
  cargo:warning=src/../include/cxx.h:52:49: error: expected ';' at end of declaration list
  cargo:warning=  static String lossy(const char *, std::size_t) noexcept;
  cargo:warning=                                                ^
  cargo:warning=                                                ;
  cargo:warning=src/../include/cxx.h:53:40: error: expected ';' at end of declaration list
  cargo:warning=  static String lossy(const char16_t *) noexcept;
  cargo:warning=                                       ^
  cargo:warning=                                       ;
  cargo:warning=src/../include/cxx.h:54:53: error: expected ';' at end of declaration list
  cargo:warning=  static String lossy(const char16_t *, std::size_t) noexcept;
  cargo:warning=                                                    ^
  cargo:warning=                                                    ;
  cargo:warning=src/../include/cxx.h:56:37: warning: reference qualifiers on functions are a C++11 extension [-Wc++11-extensions]
  cargo:warning=  String &operator=(const String &) &noexcept;
  cargo:warning=                                    ^
  cargo:warning=src/../include/cxx.h:56:38: error: expected ';' at end of declaration list
  cargo:warning=  String &operator=(const String &) &noexcept;
  cargo:warning=                                     ^
  cargo:warning=                                     ;
  cargo:warning=src/../include/cxx.h:57:28: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  cargo:warning=  String &operator=(String &&) &noexcept;
  cargo:warning=                           ^
  cargo:warning=src/../include/cxx.h:57:32: warning: reference qualifiers on functions are a C++11 extension [-Wc++11-extensions]
  cargo:warning=  String &operator=(String &&) &noexcept;
  cargo:warning=                               ^
  cargo:warning=src/../include/cxx.h:57:33: error: expected ';' at end of declaration list
  cargo:warning=  String &operator=(String &&) &noexcept;
  cargo:warning=                                ^
  cargo:warning=                                ;
  cargo:warning=src/../include/cxx.h:59:3: warning: explicit conversion functions are a C++11 extension [-Wc++11-extensions]
  cargo:warning=  explicit operator std::string() const;
  cargo:warning=  ^~~~~~~~
  cargo:warning=src/../include/cxx.h:62:27: error: expected ';' at end of declaration list
  cargo:warning=  const char *data() const noexcept;
  cargo:warning=                          ^
  cargo:warning=                          ;
  cargo:warning=src/../include/cxx.h:63:27: error: expected ';' at end of declaration list
  cargo:warning=  std::size_t size() const noexcept;
  cargo:warning=                          ^
  cargo:warning=                          ;
  cargo:warning=src/../include/cxx.h:64:29: error: expected ';' at end of declaration list
  cargo:warning=  std::size_t length() const noexcept;
  cargo:warning=                            ^
  cargo:warning=                            ;
  cargo:warning=src/../include/cxx.h:65:21: error: expected ';' at end of declaration list
  cargo:warning=  bool empty() const noexcept;
  cargo:warning=                    ^
  cargo:warning=                    ;
  cargo:warning=src/../include/cxx.h:67:22: error: expected ';' at end of declaration list
  cargo:warning=  const char *c_str() noexcept;
  cargo:warning=                     ^
  cargo:warning=                     ;
  cargo:warning=src/../include/cxx.h:69:31: error: expected ';' at end of declaration list
  cargo:warning=  std::size_t capacity() const noexcept;
  cargo:warning=                              ^
  cargo:warning=                              ;
  cargo:warning=src/../include/cxx.h:70:31: error: expected ';' at end of declaration list
  cargo:warning=  void reserve(size_t new_cap) noexcept;
  cargo:warning=                              ^
  cargo:warning=                              ;
  cargo:warning=src/../include/cxx.h:72:20: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
  cargo:warning=  using iterator = char *;
  cargo:warning=                   ^
  cargo:warning=src/../include/cxx.h:73:19: error: expected ';' at end of declaration list
  cargo:warning=  iterator begin() noexcept;
  cargo:warning=                  ^
  cargo:warning=                  ;
  cargo:warning=fatal error: too many errors emitted, stopping now [-ferror-limit=]
  cargo:warning=8 warnings and 20 errors generated.
  exit status: 1

  --- stderr

  error occurred: Command env -u IPHONEOS_DEPLOYMENT_TARGET "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-Wall" "-Wextra" "-o" "/var/folders/25/4w83mpb16zv6m8pxz9w5b1qm0000gn/T/cargo-installCICpWT/release/build/cxx-ec000d7171a5aab8/out/src/cxx.o" "-c" "src/cxx.cc" with args "c++" did not execute successfully (status code exit status: 1).

warning: build failed, waiting for other jobs to finish...
error: failed to compile `pineappl_cli v0.6.3`, intermediate artifacts can be found at `/var/folders/25/4w83mpb16zv6m8pxz9w5b1qm0000gn/T/cargo-installCICpWT`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

The problem can be solved by doing export CXX="c++ -std=c++11"

CC: @cschwan

cschwan commented 6 months ago

The problem as mentioned above is that C++ files are compiled without the -std=c++11 flag, but I can't see where this flag would be missing on my box I get

[cxx 1.0.85] running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-Wall" "-Wextra" "-std=c++11" "-o" "/scratch/cschwan/cargo-target/pineappl/release/build/cxx-dbfb4779dc2c8786/out/src/cxx.o" "-c" "src/cxx.cc"

which does have the missing flag.

cschwan commented 6 months ago

This is possibly a problem in cxx: https://github.com/dtolnay/cxx/issues/1217.

cschwan commented 4 months ago

This is possibly fixed in commit b1036ae911742b7a88c5588c02386aafa4e43170. @andreab1997 would please verify this? Follow this list:

  1. make sure that the output of echo $CXX is empty
  2. run cargo install --locked --git https://github.com/NNPDF/pineappl.git pineappl_cli.

Hopefully there are no problems anymore.

cschwan commented 4 months ago

Note to myself: before closing this issue, write a CHANGELOG.md entry.

alecandido commented 4 months ago

Just to mention: for me, it was working even before b1036ae, but with nix-darwin (not Xcode CLI tools, nor Homebrew). For me, cc is clang-11, and I have no $CXX set.

It's funny, because the original author of the issue in cc-rs is a NixOS release manager...

I'm running:

cargo install --locked --path ./pineappl_cli --root target/prefix

and I updated the flake in the nix branch with the reproducible environment.

cschwan commented 3 months ago

I assume this problem has been fixed. If that's not the case, please open a new Issue.