2

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 clang-toolchain@14.0.0 breaks when installed alongside gcc-toolchain@11.2.0. 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 clang-toolchain@14.0.0 gcc-toolchain@11.2.0 --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 gcc-toolchain@10.3:

guix shell clang-toolchain@14.0.0 gcc-toolchain@10.3.0 --container -- clang++ main.cpp  

Output: Expected file(a.out) is produced

aarongile
  • 83
  • 1
  • 5
  • Your error is a syntax error, missing `;`, not a deprecation error. I would check your installed library headers. Probably wrong. – Taekahn Apr 29 '22 at 01:07
  • The message doesn't really make sense, since the `;` is there in the code line shown in the message. The only explanation I have is that the macro expanded to something that clang doesn't understand, but I don't know why that should happen. How exactly did you install the toolchain and run the compiler? Since you are using guix, you should probably be able to provide a reproducible setup. – user17732522 Apr 29 '22 at 02:08
  • @user17732522 I installed the toolchain using a regular Guix command: `guix package install clang-toolchain` – aarongile Apr 29 '22 at 02:26
  • I only have limited experience with guix, but what does e.g. `guix describe --format=channels` say about your environment? If you are simply running a default guix installation, I think you will be more successful reporting it as a bug to guix or asking their mailing list for help. If you modified something from a default installation, you should probably mention that. `guix package --export-manifest` might also help for reproducibility. – user17732522 Apr 29 '22 at 02:34
  • @user17732522 I did run both commands you suggested. The first command only shows the channels current in use. I use ```flatwhatson``` for Emacs, but that's about it. ```guix package --export-manifest``` returns empty output. – aarongile Apr 29 '22 at 17:22
  • @aarongile `guix describe --format=channels` contains the commit hash of guix and additional channels which you are using. Knowing it would help others exactly reproducing your situation. I don't really see the linked bug report being the same problem. It fails there at a different point in the standard library headers. Anyway, I won't have time to try to reproduce it on my system. Maybe someone else does. – user17732522 Apr 29 '22 at 19:43

0 Answers0