Skip to content

Compilation with LLVM fails on Linux Rocky9/Ubuntu-22.04 - stdlib incorrectly chosen #969

Open
@dslarm

Description

@dslarm

In CMakeLists.txt, check_cxx_compiler_flag(-stdlib=libc++ HAVE_LIBCPP) is used to determine whether to use LLVM's C++ stdlib - libc++, or the system's own GNU one (libstdc++).

Unfortunately, those distros do not ship with that library (per the clip below) - and yet the test succeeds - yielding failure later in the build process due to lots of missing header files.

[rocky@ip-10-11-36-33 ~]$ cat >test.cpp
#include <iostream>

int main() {
std::cout << "Helloworld";
}
[rocky@ip-10-11-36-33 ~]$ clang++ -stdlib=libc++ test.cpp 
test.cpp:1:10: fatal error: 'iostream' file not found
    1 | #include <iostream>
      |          ^~~~~~~~~~
1 error generated.

The cause is that CMake's check_cxx_compiler_flag(-stdlib=libc++ HAVE_LIBCPP) test which is used in Salmon only tests if the compiler accepts the flag (the test code it uses doesn't have any includes - just main() {return 0;}) rather than if it works.

I don't know the whys behind the missing library - the library is available on OS/X for example - however it seems this behaviour should be changed for now on Linux platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions