Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

llvm, char16_t, and target windows

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
franta
n00b
n00b
Posts: 6
Joined: Tue Jul 26, 2022 9:03 am

llvm, char16_t, and target windows

  • Quote

Post by franta » Fri Jul 07, 2023 10:59 am

I have a C++ program

Code: Select all

// a.cpp
typedef char16_t mychar;
and compile it with clang++:

Code: Select all

franta@here ~ $clang++ -fno-PIE --target=x86_64-unknown-windows -c a.cpp 
a.cpp:2:9: error: unknown type name 'char16_t'
typedef char16_t mychar;
        ^
1 error generated.
whereas, with linux target, it compiles just fine:

Code: Select all

franta@here ~ $ clang++ -fno-PIE --target=x86_64-unknown-linux -c a.cpp
franta@here ~ $
The versions of clang is

Code: Select all

franta@here ~ $ clang++ --version
clang version 16.0.5
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/16/bin
Configuration file: /etc/clang/clang++.cfg
I cannot figure out why clang does not recognise char16_t with that architecture, it does on other distros I tried.
Is this a bug, a feature, something else?

However, if I change char16_t to built-in __char16_t:

Code: Select all

// b.cpp
typedef __char16_t mychar;
then it's compiled just fine:

Code: Select all

franta@here ~ $ clang++ -fno-PIE --target=x86_64-unknown-linux -c b.cpp
franta@here ~ $
My working assumption is that there is essentially a bug in Gentoo llvm headers as opposed to
upstream and that there is a typedef missing in one of the headers that are loaded implicitly.
I don't understand the whole interplay of the pieces involved enough though to figure out,
why it works with one triple, but not the other.

Any suggestions how to track this down?
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2113
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

Re: llvm, char16_t, and target windows

  • Quote

Post by GDH-gentoo » Fri Jul 07, 2023 9:59 pm

franta wrote:I have a C++ program

Code: Select all

// a.cpp
typedef char16_t mychar;
and compile it with clang++:

Code: Select all

franta@here ~ $clang++ -fno-PIE --target=x86_64-unknown-windows -c a.cpp 
a.cpp:2:9: error: unknown type name 'char16_t'
typedef char16_t mychar;
        ^
1 error generated.
Post the output of that command when adding the --verbose option.
Ionen wrote:As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Top
franta
n00b
n00b
Posts: 6
Joined: Tue Jul 26, 2022 9:03 am

  • Quote

Post by franta » Sat Jul 08, 2023 10:52 am

The failing windows triple:
franta@here ~ $ clang++ --std=c++2b -fno-PIE --target=x86_64-unknown-windows -c --verbose a.cpp
clang version 16.0.5
Target: x86_64-unknown-windows-msvc
Thread model: posix
InstalledDir: /usr/lib/llvm/16/bin
Configuration file: /etc/clang/clang++.cfg
System configuration file directory: /etc/clang
(in-process)
"/usr/lib/llvm/16/bin/clang-16" -cc1 -triple x86_64-unknown-windows-msvc -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name a.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/franta -resource-dir /usr/lib/llvm/16/bin/../../../../lib/clang/16 -include /usr/include/gentoo/fortify.h -include /usr/include/gentoo/maybe-stddefs.h -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm/16/bin/../../../../lib/clang/16/include -internal-externc-isystem /usr/include --std=c++2b -fdeprecated-macro -fdebug-compilation-dir=/home/franta -ferror-limit 19 -stack-protector 2 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fno-threadsafe-statics -fdelayed-template-parsing -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o a.o -x c++ a.cpp
clang -cc1 version 16.0.5 based upon LLVM 16.0.5 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/llvm/16/bin/../../../../lib/clang/16/include
/usr/include
End of search list.
a.cpp:2:9: error: unknown type name 'char16_t'
typedef char16_t mychar;
^
1 error generated.
with linux triple:
franta@here ~ $ clang++ --std=c++2b -fno-PIE --target=x86_64-unknown-linux -c --verbose a.cpp
clang version 16.0.5
Target: x86_64-unknown-linux
Thread model: posix
InstalledDir: /usr/lib/llvm/16/bin
Configuration file: /etc/clang/clang++.cfg
System configuration file directory: /etc/clang
Selected GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
(in-process)
"/usr/lib/llvm/16/bin/clang-16" -cc1 -triple x86_64-unknown-linux -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name a.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/franta -resource-dir /usr/lib/llvm/16/bin/../../../../lib/clang/16 -include /usr/include/gentoo/fortify.h -include /usr/include/gentoo/maybe-stddefs.h -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12 -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/x86_64-pc-linux-gnu -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/backward -internal-isystem /usr/lib/llvm/16/bin/../../../../lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include --std=c++2b -fdeprecated-macro -fdebug-compilation-dir=/home/franta -ferror-limit 19 -stack-protector 2 -fstack-clash-protection -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o a.o -x c++ a.cpp
clang -cc1 version 16.0.5 based upon LLVM 16.0.5 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/backward
/usr/lib/llvm/16/bin/../../../../lib/clang/16/include
/usr/include
End of search list.
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2113
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

  • Quote

Post by GDH-gentoo » Sat Jul 08, 2023 5:06 pm

franta wrote:The failing windows triple:

Code: Select all

franta@here ~ $ clang++ --std=c++2b -fno-PIE --target=x86_64-unknown-windows -c --verbose a.cpp 
clang version 16.0.5
Target: x86_64-unknown-windows-msvc
...
 "/usr/lib/llvm/16/bin/clang-16" -cc1 -triple x86_64-unknown-windows-msvc ... -o a.o -x c++ a.cpp
I have slightly different results compiling your example with Clang 15.0.7 straight from a stage3 archive from some months ago:

Code: Select all

$ clang++ -v -c -fno-pie --target=x86_64-unknown-windows a.cpp 
clang version 15.0.7
Target: x86_64-unknown-windows-msvc
...
 "/usr/lib/llvm/15/bin/clang-15" -cc1 -triple x86_64-unknown-windows-msvc19.20.0 ... -o a.o -x c++ a.cpp
First, notice that target x86_64-unknown-windows means x86_64-unknown-windows-msvc, i.e. compatibility with Microsoft Visual C and C++ (MSVC). Second, notice that my clang-15 gets a triplet that has an MSVC version appended by default, 19.20.0, and your clang-16 doesn't.

So I tried passing complete targets, and found that the example compiles with --target=x86_64-unknown-windows-msvc19, but I get the same error passing --target=x86_64-unknown-windows-msvc18.99. So a) Clang seems to think that there is a compatibility problem with certain versions of MSVC when a program uses keyword char16_t, and b) I don't know why your Clang doesn't get a triplet with an MSVC version.
Ionen wrote:As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Top
Post Reply

4 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic