Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ayakael opened this issue Sep 13, 2022 · 5 comments
Closed

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

ayakael opened this issue Sep 13, 2022 · 5 comments

Comments

@ayakael
Copy link
Contributor

ayakael commented Sep 13, 2022

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.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 13, 2022
@ghost
Copy link

ghost commented Sep 13, 2022

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

Issue Details

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.

Author: ayakael
Assignees: -
Labels:

area-Infrastructure-coreclr, untriaged

Milestone: -

@jkotas
Copy link
Member

jkotas commented Sep 13, 2022

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}")

@ayakael
Copy link
Contributor Author

ayakael commented Sep 13, 2022

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!

@ayakael ayakael closed this as completed Sep 13, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Sep 13, 2022
@jkotas
Copy link
Member

jkotas commented Sep 13, 2022

Let's keep this open for .NET 7 backport

@jkotas jkotas added this to the 7.0.0 milestone Sep 13, 2022
@jkotas jkotas reopened this Sep 13, 2022
jkotas added a commit to jkotas/runtime that referenced this issue Sep 13, 2022
Port dotnet@ee77955 to fix building with clang-14 that is used by the most recent Linux distros

Fixes dotnet#75505
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Sep 13, 2022
carlossanlop pushed a commit that referenced this issue Sep 13, 2022
Port ee77955 to fix building with clang-14 that is used by the most recent Linux distros

Fixes #75505
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Sep 13, 2022
@hoyosjs
Copy link
Member

hoyosjs commented Sep 20, 2022

Fixed in 7.0 and 6.0.

@hoyosjs hoyosjs closed this as completed Sep 20, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants