Skip to content

clang-14: unknown argument: '-gcc-toolchain' #75505

Closed

Description

@ayakael

Description

During crossbuild of 7.0-preview7 with clang-14 on Alpine Linux, build fails with the following error on multiple files:

clang-14: error: unknown argument: '-gcc-toolchain'

This is due to clang-14 removing parsing of -gcc-toolchain in favor or --gcc-toolchain=

Reproduction Steps

Clone tag v7.0.0-preview.7.22375.6
Build using ROOTFS_DIR="$CBUILDROOT" ./build.sh -arch arm64 -c Release -cross -clang
where CBUILDROOT is your ROOTFS_DIR (in Alpine's case, $HOME/sysroot-arm64)

Expected behavior

--gcc-toolchain= should be used

Actual behavior

-gcc-toolchain used instead

Regression?

This also affects runtime v6.0.8

Known Workarounds

On v6.0.8, the following workaround was used:

  1. let build fail
  2. execute following to replace bad arguments
	_sedlist="
			pal/src/libunwind/src/CMakeFiles/libunwind.dir/build.make
			pal/src/CMakeFiles/coreclrpal.dir/build.make
			vm/wks/CMakeFiles/cee_wks_core.dir/build.make
			dlls/mscordac/CMakeFiles/mscordaccore.dir/build.make
			debug/di/CMakeFiles/cordbdi.dir/build.make
			debug/createdump/CMakeFiles/createdump.dir/build.make
			debug/ee/wks/CMakeFiles/cordbee_wks_obj.dir/build.make
			dlls/mscordbi/CMakeFiles/mscordbi.dir/build.make
		"
		for i in $_sedlist; do
			sed 's| -gcc-toolchain | --gcc-toolchain=|' -i artifacts/obj/coreclr/Linux.*.Release/$i || true
		done
  1. start build again

Unfortunately, this does not work on version 7.0.0-preview.7, as build.make seems to be regenerated every build.

Configuration

Alpine Edge w/ clang 14 + cmake 3.23.1
Crossbuild x86_64 -» aarc64
Tested runtime versions 6.0.8 + 7.0.0-preview.7

Other information

I have not found the reason why some build.make files use the deprecated argument. Granted, I am a layman at clang + cmake.

Activity

  1. ghost added
    untriaged
    on Sep 13, 2022
  2. ghost added
    area-Infrastructure-coreclr
    on Sep 13, 2022
  3. jkotas commented on Sep 13, 2022

    @jkotas
    Member

    Does applying this workaround fix the problem for you?

    # This is a workaround for upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22995.
    #
    # In Clang.cmake, the decision to use single or double hyphen for target and gcc-toolchain
    # is made based on CMAKE_${LANG}_COMPILER_VERSION, but CMAKE_ASM_COMPILER_VERSION is empty
    # so it picks up single hyphen options, which new clang versions don't recognize.
    set (CMAKE_ASM_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION}")

  4. ayakael commented on Sep 13, 2022

    @ayakael
    ContributorAuthor

    Does applying this workaround fix the problem for you?

    # This is a workaround for upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22995.
    #
    # In Clang.cmake, the decision to use single or double hyphen for target and gcc-toolchain
    # is made based on CMAKE_${LANG}_COMPILER_VERSION, but CMAKE_ASM_COMPILER_VERSION is empty
    # so it picks up single hyphen options, which new clang versions don't recognize.
    set (CMAKE_ASM_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION}")

    That did it, thanks!

  5. ghost removed
    untriaged
    on Sep 13, 2022
  6. jkotas commented on Sep 13, 2022

    @jkotas
    Member

    Let's keep this open for .NET 7 backport

  7. added this to the 7.0.0 milestone on Sep 13, 2022
  8. reopened this on Sep 13, 2022
  9. added a commit that references this issue on Sep 13, 2022
    2fdf4bd
  10. ghost added
    in-pr
    on Sep 13, 2022
  11. added a commit that references this issue on Sep 13, 2022
    f115515
  12. ghost removed
    in-pr
    on Sep 13, 2022
  13. hoyosjs commented on Sep 20, 2022

    @hoyosjs
    Member

    Fixed in 7.0 and 6.0.

  14. ghost locked as resolved and limited conversation to collaborators on Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Infrastructure-coreclr

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions