Installed clang 14.0 using GNU/Guix's clang-toolchain package. I am getting depreciated feature usage error when trying to compile a simple code:
//build with: clang++ main.cpp
//main.cpp
#include <iostream>
int main() {
std::cout << "hello world!" << std::endl;
}
The error message is:
[Guix profile dir]/include/c++/backward/binders.h:130:6: error: expected ';' after class
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
The error happens regardless of which STL header
the code includes. For example, it fails when <string>
is included with the same error message.
Any idea how to resolve the error?
Update 1: This seems to be a configuration error. It goes away if the compilation is done inside a Guix container environment:
guix environment --container clang-toolchain -- clang++ main.cpp -o main
Update 2:
[This turned out to be WRONG. It is related to lack of multilib support in gcc-toolchain]
The error still persists when running the same code in a Guix environment with the --pure
option. This means the
error isn't due to environment setting.
There is also an older bug report addressing the same issue: https://bugzilla.redhat.com/show_bug.cgi?id=1896076. The
error message in the bug can be reproduced when running
the test code using emscripten:
emcc -o main.html main.cpp
The problem is the bug was already addressed in Fedora 33?
I am currently on: Linux/fedora 5.17.4-200.fc35.x86_64 with
a Guix environment: guix describe --format=channels
:
(list (channel
(name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git")
(branch "master")
(commit
"59b91fdbcd7e1a88d1d54d392ce5d5fddd9d96d1")
(introduction
(make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad"
(openpgp-fingerprint
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"))))
(channel
(name 'flat)
(url "https://github.com/flatwhatson/guix-channel.git")
(branch "master")
(commit
"f43c67e47f1ca83d045f35c31772c5e4eb64b2a2")
(introduction
(make-channel-introduction
"33f86a4b48205c0dc19d7c036c85393f0766f806"
(openpgp-fingerprint
"736A C00E 1254 378B A982 7AF6 9DBE 8265 81B6 4490")))))
Update 3: It seems the latest [email protected] breaks when installed alongside [email protected]. That is, in the same Guix profile. Downgrading gcc-toolchain to version 10.3.0 resolved the error.
The issue can be reproduced with:
guix shell [email protected] [email protected] --container -- clang++ main.cpp
Output:
In file included from main.cpp:1:
In file included from /gnu/store/../profile/include/c++/iostream:39:
In file included from /gnu/store/../profile/include/c++/ostream:38:
In file included from /gnu/store/../profile/include/c++/ios:42:
In file included from /gnu/store/../profile/include/c++/bits/ios_base.h:41:
In file included from /gnu/store/../profile/include/c++/bits/locale_classes.h:40:
In file included from /gnu/store/../profile/include/c++/string:48:
In file included from /gnu/store/../profile/include/c++/bits/stl_function.h:1407:
/gnu/store/../profile/include/c++/backward/binders.h:130:6: error: expected ';' after class
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
^
/gnu/store/../profile/include/c++/backward/binders.h:130:7: error: C++ requires a type specifier for all declarations
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
^
/gnu/store/../profile/include/c++/backward/binders.h:165:6: error: expected ';' after class
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
^
/gnu/store/../profile/include/c++/backward/binders.h:165:7: error: C++ requires a type specifier for all declarations
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
Downgrading gcc to [email protected]:
guix shell [email protected] [email protected] --container -- clang++ main.cpp
Output: Expected file(a.out) is produced