<div dir="ltr"><div>This is currently not supported. We only support building universal binaries in the compiler-rt build.</div><div><br></div><div>I'd like to introduce support for building universal binaries for other runtimes as well, but I don't know yet what's the right strategy.</div><div><br></div><div>The way compiler-rt approaches the problem is by creating a separate target for each supported system and architecture and then combining the output artifacts. This is all done within a single CMake build.<br></div><div><br></div><div>In the runtimes build, we use a separate CMake build for each target. You could build all other runtimes for different targets using that approach and then combine the output together. That's the approach that Apple uses in <a href="https://github.com/llvm/llvm-project/blob/main/libcxx/utils/ci/apple-install-libcxx.sh">https://github.com/llvm/llvm-project/blob/main/libcxx/utils/ci/apple-install-libcxx.sh</a></div><div><br></div><div>We could implement universal binary support in the runtimes, combining output artifacts with llvm-lipo. What I don't know is how to fit the compiler-rt build into that model. I can see two ways forward:</div><div><br></div><div>1. We implement the same approach that compiler-rt uses in other runtimes, that is we implement support for building libc++, libc++abi and libunwind for multiple targets within a single CMake build. In the runtimes build, we then use a single target for the "universal build".</div><div>2. We implement universal binary support in the runtimes build and we stop using the existing support in the compiler-rt build when targeting Apple platforms.</div><div><br></div><div>I'm leaning towards #2 which seems like a better long term strategy but I'd like to hear from Chris who has already looked into this problem in the past. Have I missed anything? Is there another approach that you'd prefer?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 20, 2021 at 9:59 AM Ken Cunningham via libcxx-dev <<a href="mailto:libcxx-dev@lists.llvm.org">libcxx-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>Hello,</div><div><br></div><div>First of all apologies for the niche question. As part of our older systems support on MacPorts, I am attempting a universal runtimes build of libcxx and libcxxabi using gcc8 as the initial build compiler. Currently I am using the llvm-7.1.0 tree for this.</div><div><br></div><div>The clang bootstrap compiler is to be built as native arch, then I would like to use that clang to make the universal runtimes.</div><div><br></div><div>We use the following initially to make sure that gcc8 builds the bootstrap compiler in the native arch:</div><div><br></div><div><font face="Menlo"><span style="font-size:11px">CMAKE_OSX_ARCHITECTURES=“x86_64”</span></font></div><div><br></div><div>This actually works just fine to generate libcxx/libcxxabi in the native arch, but try as I may, I cannot find a way to make libcxx and libcxxabi build as universal binaries using the bootstrap compiler.</div><div><br></div><div>I tried adding runtime targets:</div><div><br></div><div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DLLVM_ENABLE_RUNTIME_TARGETS="i386-apple-darwin10;x86_64-apple-darwin10”</span></div></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><span style="font-family:Helvetica;font-size:12px">or just forcing the CXXFLAGS and CCFLAGS to include “-arch i386 -arch x86_64” but no luck.</span></span></div><div><br></div><div>I was wondering if first of all building the runtimes as universal is supported (I know it is in compiler-rt) and if so, is there an approach or runtimes configuration option I am meant to set for this?</div><div><br></div><div>Best,</div><div><br></div><div>Ken</div><div><br></div><div><br></div><div><br></div><div>Our current configure line looks like this, with a bunch of MacPorts’ standard cmake defaults in there:</div><div><br></div><div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">cd "/opt/local/var/macports/build/_opt_myports_lang_libcxx/libcxx/work/build" && </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">CXX=g++-8.0 CC=gcc-8.0 </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">cmake -G "CodeBlocks - Unix Makefiles” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_BUILD_TYPE=Release </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_INSTALL_PREFIX="/opt/local” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_INSTALL_NAME_DIR="/opt/local/lib” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_SYSTEM_PREFIX_PATH="/opt/local;/usr” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_C_COMPILER_LAUNCHER=/opt/local/bin/ccache </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_CXX_COMPILER_LAUNCHER=/opt/local/bin/ccache </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_C_COMPILER="$CC” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_CXX_COMPILER="$CXX” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_OBJC_COMPILER="$CC” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_OBJCXX_COMPILER="$CXX” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_POLICY_DEFAULT_CMP0025=NEW </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_POLICY_DEFAULT_CMP0060=NEW </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_VERBOSE_MAKEFILE=ON </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_COLOR_MAKEFILE=ON </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_FIND_FRAMEWORK=LAST </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_EXPORT_COMPILE_COMMANDS=ON </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_MAKE_PROGRAM=/usr/bin/make </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_MODULE_PATH="/opt/local/share/cmake/Modules” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_PREFIX_PATH="/opt/local/share/cmake/Modules” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_INSTALL_RPATH="/opt/local/lib"</span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DPYTHON_EXECUTABLE=/opt/local/libexec/libcxx-bootstrap/bin/python2.7 </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DLIBXML2_LIBRARIES=IGNORE </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_OSX_ARCHITECTURES="x86_64” </span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_OSX_DEPLOYMENT_TARGET="10.6” </span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">-DCMAKE_OSX_SYSROOT=“/“ </span></div><div>-DLLVM_TARGETS_TO_BUILD="X86” </div></span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DLLVM_ENABLE_PROJECTS="clang” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi” </span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo">/opt/local/var/macports/build/_opt_myports_lang_libcxx/libcxx/work/libcxx-7.1.0/llvm </div></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo">&& make install-cxx install-cxxabi</div></div>_______________________________________________<br>
libcxx-dev mailing list<br>
<a href="mailto:libcxx-dev@lists.llvm.org" target="_blank">libcxx-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev</a><br>
</blockquote></div></div>