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

Target triple option #92

Closed
dileks opened this issue May 21, 2020 · 12 comments
Closed

Target triple option #92

dileks opened this issue May 21, 2020 · 12 comments

Comments

@dileks
Copy link
Contributor

dileks commented May 21, 2020

Since I use tc-build I see in my logs:

$ grep warning: build-log_5.7.0-rc6-2-amd64-clang.txt 
dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-unknown-linux-gnu, try setting a correct CC environment variable

My generated clang-10 says Target: x86_64-unknown-linux-gnu:

$ clang-10 -v
ClangBuiltLinux clang version 10.0.1 (https://github.com/llvm/llvm-project f79cd71e145c6fd005ba4dd1238128dfa0dc2cb6)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dileks/src/llvm-toolchain/install/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

Whereas Debian's gcc-10 says Target: x86_64-linux-gnu:

$ gcc-10 -v
Using built-in specs.
COLLECT_GCC=gcc-10
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.1.0-1' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,amdgcn-amdhsa,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.1.0 (Debian 10.1.0-1)

So an option is desired to pass "triple"for the target(s).
Unsure which target triple options are allowed in the LLVM world.

Thanks.

@nathanchance
Copy link
Member

I don’t really know how building kernels with dpkg works but I am fairly certain that the “unknown” part of the tuple comes from the fact that we set CLANG_VENDOR to ClangBuiltLinux. You could try adding --clang-vendor “” to build-llvm.py and seeing if that fixes it but other than that, I do not really have any solution to offer to you. If there is a way to add --target=x86_64-linux-gnu to KCFLAGS, that might also work.

@dileks
Copy link
Contributor Author

dileks commented May 22, 2020

Thanks for the feedback.

I checked the target-triple of clang-10 from llvm-toolchain-buster-10 (here: Target: x86_64-pc-linux-gnu):

# /usr/bin/clang-10 -v
clang version 10.0.1-++20200519101155+f79cd71e145-1~exp1~20200519202550.165 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

I tried --clang-vendor “”AFAICS it needed an argument - empty string seems not to be allowed.
That's why I passed --clang-vendor “dileks" (note: with some individual versioning hacks):

$ clang-10 -v
dileks clang version 10.0.1rc1 
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dileks/src/llvm-toolchain/install/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

Is it possible to pass individual "extra" options to tc-build?
Of course, with a check beforehand if it is allowed :-).

@dileks
Copy link
Contributor Author

dileks commented May 22, 2020

I checked debian/rules file of llvm-toolchain-10 package from sources.debian.org.

Looks like the required cmake option is -DLLVM_HOST_TRIPLE=x86_64-pc-linux-gnu.

See reference [1] to set -DLLVM_HOST_TRIPLE=arm-linux-gnueabi.

[1] https://sources.debian.org/src/llvm-toolchain-10/1:10.0.1%7E+rc1-1%7Eexp1/debian/rules/#L99

@dileks
Copy link
Contributor Author

dileks commented May 22, 2020

I tried this:

[ build-llvm.py ]

def base_cmake_defines(dirs):
...
+        # Explicitly set LLVM_HOST_TRIPLE (see <https://github.com/ClangBuiltLinux/tc-build/issues/92>). -dileks
+        'LLVM_HOST_TRIPLE': 'x86_64-pc-linux-gnu',

My build-log now says:

-- LLVM host triple: x86_64-pc-linux-gnu
-- LLVM default target triple: x86_64-pc-linux-gnu

@dileks
Copy link
Contributor Author

dileks commented May 22, 2020

I was not able to pass an empty string thus the brutal way:

[ build-llvm.py ]

def parse_parameters(root_folder):
...
-                        default="ClangBuiltLinux")
+                        default="")

With the above change together clang-10 -v says:

$ ./build/stage1/bin/clang-10 -v
clang version 10.0.1rc1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /home/dileks/src/llvm-toolchain/./build/stage1/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

@nathanchance
Copy link
Member

I don't want to hardcode the host triple because the script can actually run on arm64 (it does not work great but it runs) and at the same time, I do not want to add a heuristic to the script for figuring out what the host triple should be.

Looking into handling an empty --clang-vendor probably seems worthwhile.

@dileks
Copy link
Contributor Author

dileks commented May 22, 2020

Looking into handling an empty --clang-vendor probably seems worthwhile.

Agreed and thanks for taking care @nathanchance

@dileks
Copy link
Contributor Author

dileks commented May 22, 2020

Can I pass some cmake-options together with build-llvm.py on the command-line?

CMAKE_OPTIONS=... ./build-llvm.py ...

[CMake] Pass LLVM_HOST_TRIPLE to external projects see [1].

[1] https://reviews.llvm.org/D40515

@dileks
Copy link
Contributor Author

dileks commented May 22, 2020

No good triple x86_64-pc-linux-gnu:

$ grep warning: build-log_5.7.0-rc6-4-amd64-clang.txt 
dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-pc-linux-gnu, try setting a correct CC environment variable

Next try:

[ build-llvm.py ]

def base_cmake_defines(dirs):

+        # Don't append version control revision info (Git revision id) to the compiler version
+        'LLVM_APPEND_VC_REV': 'OFF',
+        # Explicitly set LLVM_HOST_TRIPLE (see <https://github.com/ClangBuiltLinux/tc-build/issues/92>). -dileks
+        'LLVM_HOST_TRIPLE': 'x86_64-linux-gnu',

@dileks
Copy link
Contributor Author

dileks commented May 22, 2020

LOL:

$ ./build/stage1/bin/clang-10 -v
clang version 10.0.1rc1 
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dileks/src/llvm-toolchain/./build/stage1/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

@dileks
Copy link
Contributor Author

dileks commented May 22, 2020

My snippet:

[ build-llvm.py ]

def base_cmake_defines(dirs):
...
+        # Explicitly set LLVM_HOST_TRIPLE to workaround target triple "x86_64-unknown-linux-gnu" on Debian
+        # Debian/testing AMD64: default: "Target: x86_64-linux-gnu" (unsupported as LLVM_HOST_TRIPLE)
+        # For details see <https://github.com/ClangBuiltLinux/tc-build/issues/92>
+        'LLVM_HOST_TRIPLE': 'x86_64-pc-linux-gnu',

You can close this if you like.

@nathanchance
Copy link
Member

Thanks. I’ll take a look at the other issue soon hopefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants