• [gentoo-dev] [PATCH 0/3] toolchain-funcs.eclass: support for querying C

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Sat Oct 8 11:50:02 2022
    Hi,

    Here's a patchset adding two new functions along with tests:

    - tc-get-cxx-stdlib() that determines C++ stdlib used (libc++ vs
    libstdc++)
    - tc-get-c-rtlib() that determines C compiler runtime used (libgcc vs
    compiler-rt)

    I've also included a fix for tests failing if ld.gold is not installed.


    Michał Górny (3):
    toolchain-funcs.eclass: Add tc-get-cxx-stdlib() to get C++ stdlib
    toolchain-funcs.eclass: Add tc-get-c-rtlib() to get CC runtime
    eclass/tests/toolchain-funcs.sh: Handle missing ld.gold gracefully

    eclass/tests/toolchain-funcs.sh | 96 ++++++++++++++++++++++-----------
    eclass/toolchain-funcs.eclass | 64 ++++++++++++++++++++++
    2 files changed, 130 insertions(+), 30 deletions(-)

    --
    2.38.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Sat Oct 8 11:50:02 2022
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/tests/toolchain-funcs.sh | 64 +++++++++++++++++----------------
    1 file changed, 34 insertions(+), 30 deletions(-)

    diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh index d8a357fb24fe..08cfd74611aa 100755
    --- a/eclass/tests/toolchain-funcs.sh
    +++ b/eclass/tests/toolchain-funcs.sh
    @@ -60,20 +60,22 @@ tbegin "tc-ld-is-gold (ld=bfd cc=bfd)"
    LD=ld.bfd LDFLAGS=-fuse-ld=bfd tc-ld-is-gold && ret=1 || ret=0
    tend ${ret}

    -tbegin "tc-ld-is-gold (ld=gold cc=default)"
    -LD=ld.gold tc-ld-is-gold
    -ret=$?
    -tend ${ret}
    -
    -tbegin "tc-ld-is-gold (ld=gold cc=bfd)"
    -LD=ld.gold LDFLAGS=-fuse-ld=bfd tc-ld-is-gold
    -ret=$?
    -tend ${ret}
    -
    -tbegin "tc-ld-is-gold (ld=bfd cc=gold)"
    -LD=ld.bfd LDFLAGS=-fuse-ld=gold tc-ld-is-gold
    -ret=$?
    -tend ${ret}
    +if type -P ld.gold &>/dev/null; then
    + tbegin "tc-ld-is-gold (ld=gold cc=default)"
    + LD=ld.gold tc-ld-is-gold
    + ret=$?
    + tend ${ret}
    +
    + tbegin "tc-ld-is-gold (ld=gold cc=bfd)"
    + LD=ld.gold LDFLAGS=-fuse-ld=bfd tc-ld
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Sat Oct 8 11:50:02 2022
    Add a new tc-get-cxx-stdlib() that attempts to get the C++ stdlib
    variant used by the current C++ compiler. Currently it supports libc++
    and libstdc++ (GCC's stdlib).

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/tests/toolchain-funcs.sh | 22 ++++++++++++++++++++
    eclass/toolchain-funcs.eclass | 36 +++++++++++++++++++++++++++++++++
    2 files changed, 58 insertions(+)

    diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh index 56379b10cded..5a35a44ce018 100755
    --- a/eclass/tests/toolchain-funcs.sh
    +++ b/eclass/tests/toolchain-funcs.sh
    @@ -198,4 +198,26 @@ for compiler in gcc clang not-really-a-compiler; do
    fi
    done

    +if type -P gcc &>/dev/null; then
    + tbegin "tc-get-cxx-stdlib (gcc)"
    + [[ $(CXX=g++ tc-get-cxx-stdlib) == libstdc++ ]]
    + tend $?
    +fi
    +
    +if type -P clang &>/dev/null; then
    + for stdlib in libc++ libstdc++; do
    + if clang++ -stdlib=${stdlib} -x c++ -E -P - &>/dev/null \
    + <<<'#include <ciso646>'
    + then
    + tbegin "tc-get-cxx-stdlib (clang, ${stdlib})"
    + [[ $(CXX=clang++ CXXFLAGS="-stdlib=${stdlib}" tc-get-cxx-stdlib) == ${stdlib} ]]
    + tend $?
    + fi
    + done
    +
    + tbegin "tc-get-cxx-stdlib (clang, invalid)"
    + ! CXX=clang++ CXXFLAGS="-st
  • From Sam James@21:1/5 to All on Sun Oct 9 23:40:01 2022
    On 8 Oct 2022, at 10:43, Michał Górny <mgorny@gentoo.org> wrote:

    Hi,

    Here's a patchset adding two new functions along with tests:

    - tc-get-cxx-stdlib() that determines C++ stdlib used (libc++ vs
    libstdc++)
    - tc-get-c-rtlib() that determines C compiler runtime used (libgcc vs
    compiler-rt)

    I've also included a fix for tests failing if ld.gold is not installed.


    All LGTM, although you forgot to CC toolchain@ ;)


    Michał Górny (3):
    toolchain-funcs.eclass: Add tc-get-cxx-stdlib() to get C++ stdlib
    toolchain-funcs.eclass: Add tc-get-c-rtlib() to get CC runtime
    eclass/tests/toolchain-funcs.sh: Handle missing ld.gold gracefully


    Best,
    sam

    -----BEGIN PGP SIGNATURE-----

    iNUEARYKAH0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCY0M9iV8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MAAKCRBzhAn1IN+R kA/YAP9Y8UfU5ozwdBF/y5/BwsA4oD/dpJiVM/e9JC2hGKtngQD/W548C2h1tuVE 0szViSEPUPRax4ASNYXvZ3+euvsUEA4=
    =96Z6
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)