Bug 8624 - No clang in build environment
Summary: No clang in build environment
Status: NEW
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Build system (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: ---
Assignee: Bugzilla mail exporter
URL:
Keywords:
Depends on: 8361
Blocks: 5878
  Show dependency treegraph
 
Reported: 2025-07-01 16:00 CEST by Pierre Ossman
Modified: 2025-07-01 16:14 CEST (History)
0 users

See Also:
Acceptance Criteria:


Attachments

Description Pierre Ossman cendio 2025-07-01 16:00:45 CEST
We've standardised on gcc as our compiler. But there is at least one case where it's insufficient, and that is for compiling modern Objective C code. For that, we'll need LLVM and clang.
Comment 1 Pierre Ossman cendio 2025-07-01 16:05:28 CEST
LLVM and clang behave very differently from gcc, so there are some extra steps we need to do.

First off, they're not built for a single target. Instead, you select the target at runtime. While flexible, it means you cannot rely on built-in details like default include and library paths.

We seem to be able to resolve most of this through two extra steps:

a) We create target specific symlinks, e.g. "arm-none-linux-gnueabi-clang++" that points at "clang++". This makes single assume an implicit "-target arm-none-linux-gnueabi".

b) We create config files for each target that specify the remaining necessary arguments. Mainly the "--sysroot" argument. clang can be built to implicitly load /etc/clang/<target>.cfg where we can put stuff.

This solves most issues. For ARM we need a bit extra, though, as the target triple doesn't say everything we want about the target system. For gcc we provide this when building gcc, but for clang we need to add these extra settings to the config file.
Comment 2 Pierre Ossman cendio 2025-07-01 16:14:21 CEST
The next major issue is the C++ standard library. The LLVM project has libc++, but we are currently using libstdc++ that's included with gcc. We likely don't want to have to keep track of multiple libraries, if nothing else to make sure everything can link safely.

Fortunately, clang supports using libstdc++. It's even the default on Linux systems.

It does some magical heuristics to find where gcc is, and hence the libstdc++ headers and libraries. But they seem to work fine with our setup, so no need to fiddle anything extra with that.


But that's only for Linux. For macOS it assumes libc++. We can easily switch this default to libstdc++, but the heuristics fail to find the headers and libraries.


Looking at the clang code, the heuristics are per platform. So that's why we're seeing different behaviours. And the heuristics for macOS seem very rudimentary and are as minimal as possible to only support the libstdc++ that Apple included back many years ago.

I can trick it, though, but putting the new libstdc++ in the same place at the old stuff. That gets everything building and linking correctly.


At which point the next issue shows up. The macOS heuristics have no support for the "-static-libstdc++" flag. Something we absolutely need as we'll be using our own version.

I even found an upstream bug report for this:

https://github.com/llvm/llvm-project/issues/76945

Note You need to log in before you can comment on or make changes to this bug.