Skip to content

Commit

Permalink
Update libunwind to LLVM 16.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
aheejin committed Aug 21, 2023
1 parent 3737863 commit e24da7e
Show file tree
Hide file tree
Showing 46 changed files with 5,792 additions and 2,370 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ See docs/process.md for more on how version tagging works.
- The `--log_html` option was removed from `emrun`. This option was already not
working with python3.8 or above so we hope is safe to say that nobody was
relying on it.
- libunwind updated to LLVM 16.0.6. (#)

3.1.44 - 07/25/23
-----------------
Expand Down
278 changes: 103 additions & 175 deletions system/lib/libunwind/CMakeLists.txt

Large diffs are not rendered by default.

64 changes: 0 additions & 64 deletions system/lib/libunwind/cmake/Modules/HandleCompilerRT.cmake

This file was deleted.

49 changes: 36 additions & 13 deletions system/lib/libunwind/cmake/Modules/HandleLibunwindFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endmacro(remove_flags)

macro(check_flag_supported flag)
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
endmacro()

macro(append_flags DEST)
Expand All @@ -63,8 +63,8 @@ endmacro()
macro(append_flags_if_supported DEST)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
append_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
append_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
endforeach()
endmacro()

Expand Down Expand Up @@ -124,6 +124,17 @@ macro(add_target_flags_if condition)
endif()
endmacro()

# Add all the flags supported by the compiler to all of
# 'CMAKE_CXX_FLAGS', 'CMAKE_C_FLAGS', 'LIBUNWIND_COMPILE_FLAGS'
# and 'LIBUNWIND_LINK_FLAGS'.
macro(add_target_flags_if_supported)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
add_target_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
endforeach()
endmacro()

# Add a specified list of flags to both 'LIBUNWIND_COMPILE_FLAGS' and
# 'LIBUNWIND_LINK_FLAGS'.
macro(add_flags)
Expand All @@ -146,8 +157,8 @@ endmacro()
macro(add_flags_if_supported)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
add_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
endforeach()
endmacro()

Expand All @@ -171,8 +182,8 @@ endmacro()
macro(add_compile_flags_if_supported)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
add_compile_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
endforeach()
endmacro()

Expand All @@ -196,8 +207,8 @@ endmacro()
macro(add_c_compile_flags_if_supported)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_c_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
add_c_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
check_c_compiler_flag("${flag}" "C_SUPPORTS_${flagname}_FLAG")
add_c_flags_if(C_SUPPORTS_${flagname}_FLAG ${flag})
endforeach()
endmacro()

Expand All @@ -221,8 +232,8 @@ endmacro()
macro(add_cxx_compile_flags_if_supported)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
add_cxx_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
add_cxx_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
endforeach()
endmacro()

Expand All @@ -246,8 +257,8 @@ endmacro()
macro(add_link_flags_if_supported)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
add_link_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
endforeach()
endmacro()

Expand All @@ -270,3 +281,15 @@ endmacro()
macro(split_list listname)
string(REPLACE ";" " " ${listname} "${${listname}}")
endmacro()

# For each specified flag, add that compile flag to the provided target.
# The flags are added with the given visibility, i.e. PUBLIC|PRIVATE|INTERFACE.
function(target_add_compile_flags_if_supported target visibility)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
if (CXX_SUPPORTS_${flagname}_FLAG)
target_compile_options(${target} ${visibility} ${flag})
endif()
endforeach()
endfunction()
42 changes: 30 additions & 12 deletions system/lib/libunwind/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ include(CMakePushCheckState)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
include(LLVMCheckCompilerLinkerFlag)
include(CheckSymbolExists)
include(CheckCSourceCompiles)

# The compiler driver may be implicitly trying to link against libunwind, which
# might not work if libunwind doesn't exist yet. Try to check if
# --unwindlib=none is supported, and use that if possible.
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)

check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)

if (NOT LIBUNWIND_USE_COMPILER_RT)
Expand All @@ -16,21 +22,33 @@ if (NOT LIBUNWIND_USE_COMPILER_RT)
endif ()
endif()

# libunwind is built with -nodefaultlibs, so we want all our checks to also
# use this option, otherwise we may end up with an inconsistency between
# libunwind is using -nostdlib++ at the link step when available,
# otherwise -nodefaultlibs is used. We want all our checks to also
# use one of these options, otherwise we may end up with an inconsistency between
# the flags we think we require during configuration (if the checks are
# performed without -nodefaultlibs) and the flags that are actually
# required during compilation (which has the -nodefaultlibs). libc is
# performed without one of those options) and the flags that are actually
# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is
# required for the link to go through. We remove sanitizers from the
# configuration checks to avoid spurious link errors.
check_c_compiler_flag(-nodefaultlibs LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")

llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
else()
llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
endif()
endif()

if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (LIBUNWIND_HAS_C_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
endif ()
if (LIBUNWIND_USE_COMPILER_RT)
find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY)
include(HandleCompilerRT)
find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY
FLAGS ${LIBUNWIND_COMPILE_FLAGS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBUNWIND_BUILTINS_LIBRARY}")
else ()
if (LIBUNWIND_HAS_GCC_S_LIB)
Expand All @@ -57,7 +75,7 @@ if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
endif ()
if (CMAKE_C_FLAGS MATCHES -fsanitize-coverage OR CMAKE_CXX_FLAGS MATCHES -fsanitize-coverage)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fsanitize-coverage=0")
endif ()
endif ()

Expand All @@ -67,13 +85,13 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unknown-pragmas")
check_c_source_compiles("
#pragma comment(lib, \"c\")
int main() { return 0; }
" LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
int main(void) { return 0; }
" C_SUPPORTS_COMMENT_LIB_PRAGMA)
cmake_pop_check_state()
endif()

# Check compiler flags
check_cxx_compiler_flag(-nostdinc++ LIBUNWIND_HAS_NOSTDINCXX_FLAG)
check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)

# Check symbols
check_symbol_exists(__arm__ "" LIBUNWIND_TARGET_ARM)
Expand Down
21 changes: 5 additions & 16 deletions system/lib/libunwind/docs/BuildingLibunwind.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The basic steps needed to build libc++ are:
* ``cd where you want to build llvm``
* ``mkdir build``
* ``cd build``
* ``cmake -G <generator> -DLLVM_ENABLE_PROJECTS=libunwind [options] <path to llvm sources>``
* ``cmake -G <generator> -DLLVM_ENABLE_RUNTIMES=libunwind [options] <llvm-monorepo>/runtimes``

For more information about configuring libunwind see :ref:`CMake Options`.

Expand Down Expand Up @@ -94,12 +94,6 @@ CMake docs or execute ``cmake --help-variable VARIABLE_NAME``.
libunwind specific options
--------------------------

.. option:: LIBUNWIND_BUILD_32_BITS:BOOL

**Default**: Same as LLVM_BUILD_32_BITS

Toggle whether libunwind should be built with -m32.

.. option:: LIBUNWIND_ENABLE_ASSERTIONS:BOOL

**Default**: ``ON``
Expand Down Expand Up @@ -148,14 +142,9 @@ libunwind specific options

Build libunwind with threading support.

.. option:: LIBUNWIND_TARGET_TRIPLE:STRING

Target triple for cross compiling

.. option:: LIBUNWIND_GCC_TOOLCHAIN:PATH

GCC toolchain for cross compiling
.. option:: LIBUNWIND_INSTALL_LIBRARY_DIR:PATH

.. option:: LIBUNWIND_SYSROOT
**Default**: ``lib${LIBUNWIND_LIBDIR_SUFFIX}``

Sysroot for cross compiling
Path where built libunwind libraries should be installed. If a relative path,
relative to ``CMAKE_INSTALL_PREFIX``.
2 changes: 1 addition & 1 deletion system/lib/libunwind/docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include(FindSphinx)
if (SPHINX_FOUND)
if (SPHINX_FOUND AND LLVM_ENABLE_SPHINX)
include(AddSphinxTarget)
if (${SPHINX_OUTPUT_HTML})
add_sphinx_target(html libunwind)
Expand Down
6 changes: 3 additions & 3 deletions system/lib/libunwind/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = '11.0'
version = '16.0'
# The full version, including alpha/beta/rc tags.
release = '11.0'
release = '16.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -242,7 +242,7 @@
#texinfo_show_urls = 'footnote'


# FIXME: Define intersphinx configration.
# FIXME: Define intersphinx configuration.
intersphinx_mapping = {}


Expand Down
20 changes: 9 additions & 11 deletions system/lib/libunwind/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,26 @@ and `Getting started with LLVM <https://llvm.org/docs/GettingStarted.html>`__.
**Bug Reports**

If you think you've found a bug in libunwind, please report it using
the `LLVM Bugzilla`_. If you're not sure, you
can post a message to the `cfe-dev mailing list`_ or on IRC.
Please include "libunwind" in your subject.
the `LLVM bug tracker`_. If you're not sure, you
can ask for support on the `Runtimes forum`_ or on IRC.
Please use the tag "libunwind" for new threads.

**Patches**

If you want to contribute a patch to libunwind, the best place for that is
`Phabricator <https://llvm.org/docs/Phabricator.html>`_. Please include [libunwind] in the subject and
add `cfe-commits` as a subscriber. Also make sure you are subscribed to the
`cfe-commits mailing list <http://lists.llvm.org/mailman/listinfo/cfe-commits>`_.
add `cfe-commits` as a subscriber. Also make sure you are subscribed to the `cfe-commits mailing list`_.

**Discussion and Questions**

Send discussions and questions to the
`cfe-dev mailing list <http://lists.llvm.org/mailman/listinfo/cfe-dev>`_.
Please include [libunwind] in the subject.
Send discussions and questions to the `Runtimes forum`_. Please add the tag "libunwind" to your post.


Quick Links
===========
* `LLVM Homepage <https://llvm.org/>`_
* `LLVM Bugzilla <https://bugs.llvm.org/>`_
* `cfe-commits Mailing List`_
* `cfe-dev Mailing List`_
* `LLVM Bug Tracker <https://github.com/llvm/llvm-project/labels/libunwind/>`_
* `Clang Discourse Forums <https://discourse.llvm.org/c/clang/6>`_
* `cfe-commits Mailing List <http://lists.llvm.org/mailman/listinfo/cfe-commits>`_
* `Runtimes Forum <https://discourse.llvm.org/tags/c/runtimes>`_
* `Browse libunwind Sources <https://github.com/llvm/llvm-project/blob/main/libunwind/>`_
Loading

0 comments on commit e24da7e

Please sign in to comment.