Skip to content

[clang][regression] Cannot build the boost library for AArch64 Linux after 20d497c26fc95c80a1bacb38820d92e5f52bec58 #101525

Open
@pawosm-arm

Description

@pawosm-arm

The boost library, even the most recent sources, has the clang.jam file which computes a target triple as such:

local rule init-flags-cross ( toolset : condition * : architecture + : address-model + : target-os )
{
    local vendor = unknown ;
    local sys = unknown ;
    switch $(target-os)
    {
        case darwin : vendor = apple ; sys = darwin ;
        case linux : vendor = pc ; sys = linux ;
    }
    local vendor-sys = $(vendor)-$(sys) ;
    for local _architecture_ in $(architecture)
    {
        for local _address-model_ in $(address-model)
        {
            local arch = unknown ;
            switch $(_architecture_)-$(_address-model_)
            {
                case arm-64 : arch = arm64 ;
                case arm-32 : arch = arm ;
                case x86-64 : arch = x86_64 ;
                case x86-32 : arch = i386 ;
            }

            toolset.flags $(toolset)
                OPTIONS $(condition)/<target-os>$(target-os)/<architecture>$(_architecture_)/<address-model>$(_address-model_)
                : "--target=$(arch)-$(vendor-sys)"
                : unchecked ;
        }
    }
}

In effect, for AArch64 Linux the target triple is arm64-pc-linux. With a target triple like that, after 20d497c commit (as pointed at by bisect), the C++ compiler cannot find the standard library headers anymore (at least when they're provided by the GCC's libstdc++).

Consider example file, std.cc:

#include <cstddef>

Try to compile it the way bjam would do it when building boost:

$ clang -c -x c++ -fvisibility-inlines-hidden -fPIC -pthread -O3 -Wall -fvisibility=hidden -Wno-inline -std=c++11 -mcpu=native -ffp-contract=fast -Wno-error=enum-constexpr-conversion -DBOOST_ALL_NO_LIB=1 -DBOOST_MPI_DYN_LINK=1 -DBOOST_MPI_PYTHON_DYN_LINK=1 -DBOOST_PYTHON_DYN_LINK=1 -DNDEBUG -I"." -I"/usr/include/python3.10" std.cc --target=arm64-pc-linux
std.cc:1:10: fatal error: 'cstddef' file not found
    1 | #include <cstddef>
      |          ^~~~~~~~~
1 error generated.

(the same would happen if aarch64-pc-linux triple is used)

Now, replace the arm64-pc-linux target triple with more appropriate aarch64-linux-gnu:

$ clang -c -x c++ -fvisibility-inlines-hidden -fPIC -pthread -O3 -Wall -fvisibility=hidden -Wno-inline -std=c++11 -mcpu=native -ffp-contract=fast -Wno-error=enum-constexpr-conversion -DBOOST_ALL_NO_LIB=1 -DBOOST_MPI_DYN_LINK=1 -DBOOST_MPI_PYTHON_DYN_LINK=1 -DBOOST_PYTHON_DYN_LINK=1 -DNDEBUG -I"." -I"/usr/include/python3.10" std.cc --target=aarch64-linux-gnu
$ file std.o
std.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped

(NB, using arm64-gnu-linux or arm64-linux-gnu triple also triggers the wrong behavior)

We could argue whether some triples are more sane than others, but sadly, boost is too popular and widely used to ignore its preference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other categoryinvalidResolved as invalid, i.e. not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions