From: Emmanuel Agullo <emmanuel.agullo@inria.fr>
To: 43023@debbugs.gnu.org
Subject: bug#43023: clang++ in a {clang-toolchain + gcc-toolchain} environment
Date: Mon, 24 Aug 2020 15:43:57 +0200 (CEST) [thread overview]
Message-ID: <109069324.10892414.1598276637610.JavaMail.zimbra@inria.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 13715 bytes --]
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")))))
└────
[-- Attachment #2: Type: text/html, Size: 20849 bytes --]
next reply other threads:[~2020-08-24 15:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 13:43 Emmanuel Agullo [this message]
2020-10-22 8:10 ` bug#43023: clang++ in a {clang-toolchain + gcc-toolchain} environment Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=109069324.10892414.1598276637610.JavaMail.zimbra@inria.fr \
--to=emmanuel.agullo@inria.fr \
--cc=43023@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).