[libcxx-commits] [PATCH] D154246: [libc++] Add check for building with picolibc

Simon Tatham via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 6 01:15:44 PDT 2023


simon_tatham added a comment.

In D154246#4474116 <https://reviews.llvm.org/D154246#4474116>, @DavidSpickett wrote:

>   clang-16: error: argument unused during compilation: '-G R-' [-Werror,-Wunused-command-line-argument]
>
> Turns out that `-GR-` is the equivalent of `/GR-` which is the msvc option to disable RTTI

That's familiar – I ran into that in another context last month. libc++ contains this in its cmake files:

  function(cxx_add_rtti_flags target)
    if (NOT LIBCXX_ENABLE_RTTI)
      target_add_compile_flags_if_supported(${target} PUBLIC -GR-)
      target_add_compile_flags_if_supported(${target} PUBLIC -fno-rtti)
    endif()
  endfunction()

and that "add_compile_flags_if_supported" is somehow misidentifying whether it's supported. Possibly //because// `-GR-` is possible to re-parse in a non-msvc-style command line as the completely different option `-G` with argument word `R-`. The fix might be to explicitly query the command-line flavour, via `if (CMAKE_C_COMPILER_ID MATCHES "MSVC" OR CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")` or something along those lines, and use that to condition the use of that MSVC option.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154246/new/

https://reviews.llvm.org/D154246



More information about the libcxx-commits mailing list