Hello, 

A typical "hello world" C++ fails in an environment with both 
`gcc-toolchain' and `clang-toolchain', apperently due to the setup of 
the `CPLUS_INCLUDE_PATH' environment variable (used because of the 
`#include <iostream>' instruction), when compiling with `clang++'. 

I do not know if this is a bug or the expected behaviour. Obviously one 
is not likely to explicitly load an environment with both `gcc-toolchain' 
and `clang-toolchain' but migth do so implictly (and possibly not being 
aware of it) for instance having `gcc-toolchain' globally installed and 
at some point loading `clang-toolchain' in an environment. 

Note that it is not critical at all in practice in my case, and I do 
not know whether it it is desirable to fix it in some way, or, maybe 
mention the incompatibility somewhere 
(<https://guix.gnu.org/manual/en/html_node/Development.html> ?) if not 
already done so – in which case I am sorry for the noise. 

Please find below: 
1. a simplified C++ "hello world" hello.cpp program 
2. an expected g++ behaviour in a `gcc-toolchain' environment 
3. an expected clang++ behaviour in a `clang-toolchain' environment 
4. an environment with both `gcc-toolchain' & `clang-toolchain' 
- 4.1. with an expected behaviour using `g++' 
- 4.2. with an (expected or not?) error using `clang++' 
- 4.3. a (non desirable) fix of the `CPLUS_INCLUDE_PATH' (removing 
`/gnu/store/…/include/c++') 
5. the employed channels if it may help 

Thanks much for the continous development and support, and once 
again sorry for the possible noise if this is a known expected 
behaviour. 

With best regards, 

Emmanuel 


1 simplified (no newline) C++ "hello world" hello.cpp program 
═════════════════════════════════════════════════════════════ 

┌──── 
│ #include <iostream> 
│ 
│ int main() { 
│ std::cout << "Hello World!"; 
│ return 0; 
│ } 
└──── 


2 `gcc-toolchain' environment 
═════════════════════════════ 

┌──── 
│ guix environment -C --ad-hoc gcc-toolchain coreutils grep 
│ env | grep CPLUS_INCLUDE_PATH 
│ g++ hello.cpp 
│ ./a.out 
└──── 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
CPLUS_INCLUDE_PATH=/gnu/store/gsylxn8q06w6y7622nw159f3q1vvcx2i-profile/include/c++:/gnu/store/gsylxn8q06w6y7622nw159f3q1vvcx2i-profile/include
 
Hello World! 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 


3 `clang-toolchain' environment 
═══════════════════════════════ 

┌──── 
│ guix environment -C --ad-hoc clang-toolchain coreutils grep 
│ env | grep CPLUS_INCLUDE_PATH 
│ clang++ hello.cpp 
│ ./a.out 
└──── 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
CPLUS_INCLUDE_PATH=/gnu/store/8qlafmilvc0g1yv8lmilpjmps3p4nrmq-profile/include 
Hello World! 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 


4 environment with both `gcc-toolchain' & `clang-toolchain' 
═══════════════════════════════════════════════════════════ 

4.1 compilation with `g++' 
────────────────────────── 

`g++' in an environment with both gcc and clang toolchains is fine: 
┌──── 
│ guix environment -C --ad-hoc gcc-toolchain clang-toolchain coreutils grep 
│ env | grep CPLUS_INCLUDE_PATH 
│ g++ hello.cpp 
│ ./a.out 
└──── 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
CPLUS_INCLUDE_PATH=/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++:/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include
 
Hello World! 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 


4.2 compilation with `clang++' (FAIL) 
───────────────────────────────────── 

But `clang++' in the same environment (with both gcc and clang 
toolchains) breaks, raising the following error: 
┌──── 
│ guix environment -C --ad-hoc gcc-toolchain clang-toolchain coreutils grep 
│ clang++ hello.cpp 
└──── 

Error obtained during the `clang++ hello.cpp' step: 
┌──── 
│ In file included from hello.cpp:1: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/iostream:39: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/ostream:38: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/ios:39: 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/exception:105:3:
 error: unknown type name '_GLIBCXX17_DEPRECATED' 
│ _GLIBCXX17_DEPRECATED 
│ ^ 
│ In file included from hello.cpp:1: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/iostream:39: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/ostream:38: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/ios:39: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/exception:147: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/bits/exception_ptr.h:40:
 
│ /gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/new:126:1: 
error: unknown type name '_GLIBCXX_NODISCARD' 
│ _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW 
(std::bad_alloc) 
│ ^ 
│ /gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/new:128:1: 
error: unknown type name '_GLIBCXX_NODISCARD' 
│ _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW 
(std::bad_alloc) 
│ ^ 
│ /gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/new:140:1: 
error: unknown type name '_GLIBCXX_NODISCARD' 
│ _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) 
_GLIBCXX_USE_NOEXCEPT 
│ ^ 
│ /gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/new:142:1: 
error: unknown type name '_GLIBCXX_NODISCARD' 
│ _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) 
_GLIBCXX_USE_NOEXCEPT 
│ ^ 
│ /gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/new:174:1: 
error: unknown type name '_GLIBCXX_NODISCARD' 
│ _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) 
_GLIBCXX_USE_NOEXCEPT 
│ ^ 
│ /gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/new:175:10: 
error: cannot initialize return object of type 'int *' with an lvalue of type 
'void *' 
│ { return __p; } 
│ ^~~ 
│ /gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/new:176:1: 
error: unknown type name '_GLIBCXX_NODISCARD' 
│ _GLIBCXX_NODISCARD inline void* operator new[](std::size_t, void* __p) 
_GLIBCXX_USE_NOEXCEPT 
│ ^ 
│ /gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/new:177:10: 
error: cannot initialize return object of type 'int *' with an lvalue of type 
'void *' 
│ { return __p; } 
│ ^~~ 
│ In file included from hello.cpp:1: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/iostream:39: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/ostream:38: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/ios:39: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/exception:148: 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/bits/nested_exception.h:40:
 
│ In file included from 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/bits/move.h:57: 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:696:27:
 error: expected unqualified-id 
│ _GLIBCXX20_DEPRECATED("use is_standard_layout && is_trivial instead") 
│ ^ 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:696:27:
 error: expected ')' 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:696:26:
 note: to match this '(' 
│ _GLIBCXX20_DEPRECATED("use is_standard_layout && is_trivial instead") 
│ ^ 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:2648:5:
 error: unknown type name '_GLIBCXX20_CONSTEXPR' 
│ _GLIBCXX20_CONSTEXPR 
│ ^ 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:2650:5:
 error: no variable template matches partial specialization 
│ _Require<__not_<__is_tuple_like<_Tp>>, 
│ ^ 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:2652:31:
 error: expected ';' at end of declaration 
│ is_move_assignable<_Tp>> 
│ ^ 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:2653:10:
 error: unknown type name '_Tp' 
│ swap(_Tp&, _Tp&) 
│ ^ 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:2653:16:
 error: unknown type name '_Tp' 
│ swap(_Tp&, _Tp&) 
│ ^ 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:2654:51:
 error: use of undeclared identifier '_Tp' 
│ noexcept(__and_<is_nothrow_move_constructible<_Tp>, 
│ ^ 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:2654:55:
 error: expected a type 
│ noexcept(__and_<is_nothrow_move_constructible<_Tp>, 
│ ^ 
│ 
/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include/c++/type_traits:2653:5:
 error: C++ requires a type specifier for all declarations 
│ swap(_Tp&, _Tp&) 
│ ^ 
│ fatal error: too many errors emitted, stopping now [-ferror-limit=] 
│ 20 errors generated. 
└──── 


4.3 (non desirable) fix of the `CPLUS_INCLUDE_PATH' (removing 
`/gnu/store/.../include/c++') 
───────────────────────────────────────────────────────────────────────────────────────────
 

For information, it is possible (but obviously in general not 
desirable) to fix the `CPLUS_INCLUDE_PATH' variable (removing 
`/gnu/store/.../include/c++'), which leads to a correct compilation 
(and execution). 

┌──── 
│ guix environment -C --ad-hoc gcc-toolchain clang-toolchain coreutils grep 
│ export 
CPLUS_INCLUDE_PATH=/gnu/store/3ka3a9wgx5sk6ac84nldx7ldpxppn29z-profile/include 
│ clang++ hello.cpp 
│ ./a.out 
└──── 

┌──── 
│ Hello World! 
└──── 


5 channels 
══════════ 

┌──── 
│ guix describe --format=channels 
└──── 

┌──── 
│ (list (channel 
│ (name 'guix-hpc) 
│ (url "https://gitlab.inria.fr/guix-hpc/guix-hpc.git";) 
│ (commit 
│ "fa87605fe93fb85b02dad9db246299bcf223f2e0")) 
│ (channel 
│ (name 'guix-hpc-non-free) 
│ (url "https://gitlab.inria.fr/guix-hpc/guix-hpc-non-free.git";) 
│ (commit 
│ "43d8cb72144a183aa7a93499f9c59ec0f84244b0")) 
│ (channel 
│ (name 'guix) 
│ (url "https://git.savannah.gnu.org/git/guix.git";) 
│ (commit 
│ "c6872990b51971922f3064cba54ab752fcdc1559") 
│ (introduction 
│ (make-channel-introduction 
│ "9edb3f66fd807b096b48283debdcddccfea34bad" 
│ (openpgp-fingerprint 
│ "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"))))) 
└──── 

Reply via email to