Skip to content

Instantly share code, notes, and snippets.

@cogwheel
Created March 20, 2024 14:46
Show Gist options
  • Save cogwheel/d6cc29c143a7169fff50ae9795eedc6c to your computer and use it in GitHub Desktop.
Save cogwheel/d6cc29c143a7169fff50ae9795eedc6c to your computer and use it in GitHub Desktop.
libcxx -> llvm-mos integration notes

Libcxx

(cogwheel)

Our type-safe unit conversions are nice, but the code to implement them is pretty verbose. llvm-mos has support for C++23, but it doesn't include much of the standard library. Here's the story of what's in the libcxx directory:

  1. Include in our source code, to find that it isn't available
  2. Go to llvm's libc++ source code and download the compare header: https://github.com/llvm/llvm-project/tree/main/libcxx
  3. Try compiling. See that it needs , download that, try again
  4. Find it needs a bunch of internal stuff, including entire directories (or at least it's easier to copy entire directories than individual files)
  5. Check out llvm-project, start copying whole directories and files 'till it stops complaining about missing files

One of the files that didn't exist was __config_site, but this is produced by a template __config_site.in

a. Rename __config_site.in to __config_site, and comment out all the cmakedefine directives b. try to compile, find what things are broken because of the missing directives c. rewrite cmakedefines to #defines as needed d. rinse and repeat until the problems no longer lead back to __config_site

Another of the files is math.h which has an include_next that needs to be disabled or it will try using the one in llvm-mos on top of the one I downloaded. It also has a couple templates and a using (fpclassify) that need to be disabled because they use floating-point related constants that are not defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment