{% extends '//builtin/run.ym' %} {% block current_version %}239236b8c2154aa49e98bc7ed774a7d2712edf50{% endblock %} {% block current_date %}2024-04-02{% endblock %} {% block keep_sources %} .yandex_meta/scripts/sysincls.py glibcxx_eh_cxx17.cpp include/__config_site include/__config_epilogue.h include/__memory/pointer_safety.h include/__support/win32/atomic_win32.h include/math_cuda.h include/stlfwd include/unwind.h include/use_ansi.h src/support/win32/atomic_win32.cpp src/support/win32/new_win32.cpp {% endblock %} {% block current_url %} {% if not local_llvm %} https://github.com/llvm/llvm-project/archive/{{self.version().strip()}}.tar.gz {% endif %} {% endblock %} {% block init_bash %} {{super()}} SYSINCLS=${WORKDIR}/sysincls {% endblock %} {% block prepare_env %} {{super()}} {% if local_llvm %} cp -R {{local_llvm.strip()}}/. ${RESOURCES}/ cd ${RESOURCES} git checkout {{self.version().strip()}} {% else %} tar xf ${RESOURCES}/{{self.current_url().strip() | basename}} --strip-components=1 --directory=${RESOURCES} {% endif %} base64 -d << EOF > ${BIN}/sysincls {% include 'scripts/sysincls.py/base64' %} EOF mkdir -p ${SYSINCLS} base64 -d << EOF > ${SYSINCLS}/stl-to-libcxx.yml {% include '//build/sysincl/stl-to-libcxx.yml/base64' %} EOF chmod +x ${BIN}/sysincls {% endblock %} {% block unpack_source %} {{super()}} rsync --recursive ${RESOURCES}/libcxx/include . rsync --recursive ${RESOURCES}/libcxx/src . cp ${RESOURCES}/libcxx/.clang-format . cp ${RESOURCES}/libcxx/CREDITS.TXT . cp ${RESOURCES}/libcxx/LICENSE.TXT . cp ${RESOURCES}/libcxx/vendor/llvm/default_assertion_handler.in include/__assertion_handler {% endblock %} {% block build_source %} {{super()}} rm src/CMakeLists.txt include/CMakeLists.txt sysincls ${SRC} ${SYSINCLS}/stl-to-libcxx.yml {% endblock %} {% block prepare_yamake %} cat << EOF > ya.make # Generated by devtools/yamaker/ym2 LIBRARY() LICENSE( Apache-2.0 AND Apache-2.0 WITH LLVM-exception AND BSL-1.0 AND MIT AND NCSA AND Unicode ) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) VERSION({{self.date().strip()}}) ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/{{self.version().strip()}}.tar.gz) SUBSCRIBER( g:cpp-committee g:cpp-contrib g:cxxsupp-contrib ) ADDINCL( GLOBAL contrib/libs/cxxsupp/libcxx/include contrib/libs/cxxsupp/libcxx/src ) CXXFLAGS(-D_LIBCPP_BUILDING_LIBRARY) IF (OS_ANDROID) SET(CXX_RT "libcxxabi_dynamic") ELSEIF (OS_IOS) SET(CXX_RT "libcxxabi_dynamic") # Yet take builtins library from Arcadia PEERDIR( contrib/libs/cxxsupp/builtins ) ELSEIF (OS_LINUX OR OS_DARWIN) IF (ARCH_ARM7) # libcxxrt support for ARM is currently broken, use libcxxabi instead # But allow switching back to glibcxx_static via -DCXX_RT=glibcxx_static DEFAULT(CXX_RT "libcxxabi") # ARM7 OS_SDK has old libstdc++ without aligned allocation support CFLAGS( GLOBAL -fno-aligned-new ) ELSE() SET(CXX_RT "libcxxrt") ENDIF() ELSEIF (OS_WINDOWS) SET(CXX_RT "msvcrt") SRCS( src/support/win32/locale_win32.cpp src/support/win32/support.cpp src/support/win32/atomic_win32.cpp src/support/win32/new_win32.cpp src/support/win32/thread_win32.cpp ) IF (CLANG_CL) PEERDIR( contrib/libs/cxxsupp/builtins ) ENDIF() ELSEIF (OS_EMSCRIPTEN) SET(CXX_RT "libcxxabi") LDFLAGS( -Wl,-Bdynamic ) CXXFLAGS( -nostdinc++ ) ENDIF() IF (CLANG) CXXFLAGS(GLOBAL -nostdinc++) ENDIF() # The CXX_RT variable controls which C++ runtime is used. # * libcxxabi - https://github.com/llvm/llvm-project/tree/main/libcxxabi from Arcadia # * libcxxabi_dynamic - https://github.com/llvm/llvm-project/tree/main/libcxxabi from SDK, dynamically linked # * libcxxrt - https://github.com/libcxxrt/libcxxrt from Arcadia (with some parts hijacked from libcxxabi) # * glibcxx_static - https://github.com/gcc-mirror/gcc/tree/master/libstdc++-v3/libsupc++ from SDK, statically linked # * msvcrt - Visual C++ runtime library from SDK, dynamically linked DISABLE(NEED_GLIBCXX_CXX17_SHIMS) DISABLE(NEED_CXX_RT_ADDINCL) IF (CXX_RT == "libcxxrt") PEERDIR( contrib/libs/cxxsupp/libcxxabi-parts contrib/libs/cxxsupp/libcxxrt contrib/libs/cxxsupp/builtins ) ADDINCL( GLOBAL contrib/libs/cxxsupp/libcxxrt/include ) CFLAGS( -DLIBCXXRT ) # These builtins are equivalent to clang -rtlib=compiler_rt and # are needed by potentially any code generated by clang. # With glibcxx runtime, builtins are provided by libgcc ELSEIF (CXX_RT == "glibcxx_static") LDFLAGS( -Wl,-Bstatic -lsupc++ -lgcc -lgcc_eh -Wl,-Bdynamic ) CXXFLAGS(-D__GLIBCXX__=1) ENABLE(NEED_GLIBCXX_CXX17_SHIMS) ENABLE(NEED_CXX_RT_ADDINCL) ELSEIF (CXX_RT == "libcxxabi") PEERDIR( contrib/libs/cxxsupp/builtins contrib/libs/cxxsupp/libcxxabi ) ADDINCL( GLOBAL contrib/libs/cxxsupp/libcxxabi/include ) CFLAGS( -DLIBCXX_BUILDING_LIBCXXABI ) ELSEIF (CXX_RT == "libcxxabi_dynamic") LDFLAGS( -lc++abi ) CFLAGS( -DLIBCXX_BUILDING_LIBCXXABI ) ELSEIF (CXX_RT == "msvcrt") # Do nothing, proper runtime will be linked by the means /MT* flags in build/ymake.core.conf ELSE() MESSAGE(FATAL_ERROR "Unexpected CXX_RT value: \${CXX_RT}") ENDIF() IF (NEED_GLIBCXX_CXX17_SHIMS) IF (GCC) # Assume GCC is bundled with a modern enough version of C++ runtime ELSEIF (OS_SDK == "ubuntu-12" OR OS_SDK == "ubuntu-14" OR OS_SDK == "ubuntu-16") # Prior to ubuntu-18, system C++ runtime for C++17 is incomplete # and requires std::uncaught_exceptions() to be implemented. SRCS( glibcxx_eh_cxx17.cpp ) ENDIF() ENDIF() IF (NEED_CXX_RT_ADDINCL) # FIXME: # This looks extremely weird and we have to use cxxabi.h from libsupc++ instead. # This ADDINCL is placed here just to fix the status quo ADDINCL( GLOBAL contrib/libs/cxxsupp/libcxxrt/include ) ENDIF() NO_UTIL() NO_RUNTIME() NO_COMPILER_WARNINGS() IF (FUZZING) NO_SANITIZE() NO_SANITIZE_COVERAGE() ENDIF() SRCS( src/algorithm.cpp src/any.cpp src/atomic.cpp src/barrier.cpp src/bind.cpp src/call_once.cpp src/charconv.cpp src/chrono.cpp src/condition_variable.cpp src/condition_variable_destructor.cpp src/error_category.cpp src/exception.cpp src/filesystem/directory_entry.cpp src/filesystem/directory_iterator.cpp src/filesystem/filesystem_clock.cpp src/filesystem/filesystem_error.cpp src/filesystem/operations.cpp src/filesystem/path.cpp src/fstream.cpp src/functional.cpp src/future.cpp src/hash.cpp src/ios.cpp src/ios.instantiations.cpp src/iostream.cpp src/legacy_pointer_safety.cpp src/locale.cpp src/memory.cpp src/memory_resource.cpp src/mutex.cpp src/mutex_destructor.cpp src/optional.cpp src/ostream.cpp src/print.cpp src/random.cpp src/random_shuffle.cpp src/regex.cpp src/ryu/d2fixed.cpp src/ryu/d2s.cpp src/ryu/f2s.cpp src/shared_mutex.cpp src/stdexcept.cpp src/string.cpp src/strstream.cpp src/system_error.cpp src/thread.cpp src/typeinfo.cpp src/valarray.cpp src/variant.cpp src/vector.cpp src/verbose_abort.cpp ) IF (NOT OS_WINDOWS) SRCS( src/new.cpp src/new_handler.cpp src/new_helpers.cpp ) ENDIF() IF (OS_LINUX) SRCS( src/time_zone.cpp src/tzdb.cpp src/tzdb_list.cpp ) ENDIF() END() EOF {% endblock %} {% block update_version %} echo "no version update" {% endblock %} {% block move_to_output %} rsync --recursive --delete --perms ${SRC}/ ${OUTPUT} {% endblock %} {% block step_install %} {{super()}} rsync ${SYSINCLS}/stl-to-libcxx.yml ${ARCADIA_ROOT}/build/sysincl/stl-to-libcxx.yml {% endblock %}