From 50014ff58b5f56490d5f8e188c856067163e56fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 26 Nov 2021 15:21:37 +0100 Subject: [PATCH 1/2] Don't output stdout from lld check This caused an issue in https://github.com/dotnet/runtime/pull/61668 because https://github.com/dotnet/runtime/blob/c00b06826ca4d333ef69d51e523ef7bd309b8631/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj#L33 sources the init-compiler.sh and uses the stdout from it and we were outputting the stdout of the lld check which broke this. Before: ``` # bash -c 'source "eng/common/native/init-compiler.sh" "eng/common/native/" x64 clang && echo $CC' LLD 10.0.1 (compatible with GNU linkers) /usr/bin/clang-10 ``` After: ``` # bash -c 'source "eng/common/native/init-compiler.sh" "eng/common/native/" x64 clang && echo $CC' /usr/bin/clang-10 ``` --- eng/common/native/init-compiler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/native/init-compiler.sh b/eng/common/native/init-compiler.sh index fd1d080e204..0f69be8db86 100755 --- a/eng/common/native/init-compiler.sh +++ b/eng/common/native/init-compiler.sh @@ -113,7 +113,7 @@ fi # Only lld version >= 9 can be considered stable if [[ "$compiler" == "clang" && "$majorVersion" -ge 9 ]]; then - if "$CC" -fuse-ld=lld -Wl,--version 2>/dev/null; then + if "$CC" -fuse-ld=lld -Wl,--version >/dev/null 2>&1; then LDFLAGS="-fuse-ld=lld" fi fi From b1f02411942ccd742be6c16005cb97db1ed088f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 26 Nov 2021 16:25:33 +0100 Subject: [PATCH 2/2] Add note about stdout --- eng/common/native/init-compiler.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/common/native/init-compiler.sh b/eng/common/native/init-compiler.sh index 0f69be8db86..e361e03fabd 100755 --- a/eng/common/native/init-compiler.sh +++ b/eng/common/native/init-compiler.sh @@ -2,6 +2,7 @@ # # This file detects the C/C++ compiler and exports it to the CC/CXX environment variables # +# NOTE: some scripts source this file and rely on stdout being empty, make sure to not output anything here! if [[ "$#" -lt 3 ]]; then echo "Usage..."