From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15343 invoked from network); 28 Jul 2023 11:14:07 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 28 Jul 2023 11:14:07 -0000 Received: (qmail 13832 invoked by uid 550); 28 Jul 2023 11:14:04 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 13792 invoked from network); 28 Jul 2023 11:14:03 -0000 X-Proofpoint-GUID: szbXzirG5AtYt9rMy5F3khzajgl2-iTb X-Proofpoint-ORIG-GUID: szbXzirG5AtYt9rMy5F3khzajgl2-iTb X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.591,18.0.957 definitions=2023-06-21_10:2023-06-14,2023-06-21 signatures=0 X-Proofpoint-Spam-Details: rule=interactive_user_notspam policy=interactive_user score=0 phishscore=0 bulkscore=0 mlxscore=0 malwarescore=0 mlxlogscore=802 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306210156 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=from : content-type : content-transfer-encoding : mime-version : subject : message-id : date : to; s=20180706; bh=YoVkzAS5s0hETUl8LwJBSQmHOXXKQdOLI6w2AFYd6dQ=; b=LDcmp5BUPFo3lW0qFTu7iNedqQD/WFPZYmomuHV8YQIwRr1awbPh4AiQiLsmY2bR8HDI f6XnkniDz7dwbqQJwKechcsOnwhuohlvi9/1/vW6H+jvqlI8dN/ffF4Tv+G4C5oAzIwe HQXCaQVC6kOJ4hTq6QQoxOnM5BnC6Zyv7GvUdB8fnMuh1u1eZYKWEQSuyRVXn/hjpI+2 VZS0MPOmqeCsfRLITDFt6WnFlRgQufXUBosQSKrRWVsMU6MxrRK8UCXDHAoY14dvGfpZ 0XXlBHBk81Ay3xXJit/HyjSt0+/e1e6pazSUz8xDSOZaz1DTMc0VvGStpG4cZPuWljEj vw== X-Va-A: X-Va-T-CD: 14dc138f66d48087821ca031f1b11e6a X-Va-E-CD: f34d6248118de6cd2f89a7d0f7908361 X-Va-R-CD: 120106e200076a19178db48982160d98 X-Va-ID: dbd27fa1-a997-4efe-a529-8a79a687d29d X-Va-CD: 0 X-V-A: X-V-T-CD: 14dc138f66d48087821ca031f1b11e6a X-V-E-CD: f34d6248118de6cd2f89a7d0f7908361 X-V-R-CD: 120106e200076a19178db48982160d98 X-V-ID: bb61622f-06d0-49bb-9467-4ac755d82332 X-V-CD: 0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.591,18.0.957 definitions=2023-07-27_10:2023-07-26,2023-07-27 signatures=0 From: Alastair Houghton Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable MIME-version: 1.0 (Mac OS X Mail 16.0 \(3769.100.3\)) Message-id: <6CAFA15F-FF1C-4343-8D7F-00A44A815CEA@apple.com> Date: Fri, 28 Jul 2023 12:13:40 +0100 To: musl@lists.openwall.com X-Mailer: Apple Mail (2.3769.100.3) Subject: [musl] [PATCH] Add options to configure script to control frame pointer omission and EH unwind information Hi there, Musl currently disables frame pointers and (except in debug builds) also = disables the emission of EH unwind information, the latter presumably in = an effort to save space. The downside of doing both of these things is = that it makes it impossible for code to generate reasonable run-time = backtraces, since without frame pointers the only way to do a stack walk = is the EH unwind data, which has been removed. These defaults are probably fine for most people, but not everybody = wants to build in this configuration, and it would be better to offer = some reasonable options here, I think. I attach a patch that adds = options to the configure script that allow users of Musl to choose * Whether to include frame pointers. * Whether to include EH unwind tables, and if so whether they should = support asynchronous unwind or not (asynchronous unwind generates more = data in the tables, since the compiler isn=E2=80=99t allowed to make = assumptions about which code could throw). Note that the existing comment in the configure script about the DWARF = tables is slightly misleading; the options the configure script uses are = to do with EH unwind data (which is for exception handling, in languages = that support it, as well as for runtime backtracing), and not with DWARF = unwind data. The two do potentially share some sections and the EH data = is stored using DWARF as a format, but it *isn=E2=80=99t* debug = information - it=E2=80=99s there for language runtime and library use. Kind regards, Alastair. =3D=3D=3D=3D Patch follows =3D=3D=3D=3D diff --git a/configure b/configure index 853bf05e..a11e0ad8 100755 --- a/configure +++ b/configure @@ -10,39 +10,42 @@ VAR=3DVALUE. See below for descriptions of some of = the useful variables. Defaults for the options are specified in brackets. =20 Configuration: - --srcdir=3DDIR source directory [detected] + --srcdir=3DDIR source directory [detected] =20 Installation directories: - --prefix=3DPREFIX main installation prefix [/usr/local/musl] - --exec-prefix=3DEPREFIX installation prefix for executable files = [PREFIX] + --prefix=3DPREFIX main installation prefix [/usr/local/musl] + --exec-prefix=3DEPREFIX installation prefix for executable files = [PREFIX] =20 Fine tuning of the installation directories: - --bindir=3DDIR user executables [EPREFIX/bin] - --libdir=3DDIR library files for the linker [PREFIX/lib] - --includedir=3DDIR include files for the C compiler = [PREFIX/include] - --syslibdir=3DDIR location for the dynamic linker [/lib] + --bindir=3DDIR user executables [EPREFIX/bin] + --libdir=3DDIR library files for the linker [PREFIX/lib] + --includedir=3DDIR include files for the C compiler = [PREFIX/include] + --syslibdir=3DDIR location for the dynamic linker [/lib] =20 System types: - --target=3DTARGET configure to run on target TARGET = [detected] - --host=3DHOST same as --target - --build=3DBUILD build system type; used only to infer = cross-compiling + --target=3DTARGET configure to run on target TARGET = [detected] + --host=3DHOST same as --target + --build=3DBUILD build system type; used only to infer = cross-compiling =20 Optional features: - --enable-optimize=3D... optimize listed components for speed over = size [auto] - --enable-debug build with debugging information [disabled] - --disable-warnings build with recommended warnings flags = [enabled] - --enable-wrapper=3D... build given musl toolchain wrapper [auto] - --disable-shared inhibit building shared library [enabled] - --disable-static inhibit building static library [enabled] + --enable-optimize=3D... optimize listed components for speed over = size [auto] + --enable-debug build with debugging information [disabled] + --disable-warnings build with recommended warnings flags = [enabled] + --enable-wrapper=3D... build given musl toolchain wrapper [auto] + --disable-shared inhibit building shared library [enabled] + --disable-static inhibit building static library [enabled] + --with-frame-pointers disable -fomit-frame-pointer [disabled] + --with-unwind-tables=3D... generate EH unwind inforormation [none] + (may be "none", "sync" or "async") =20 Optional packages: - --with-malloc=3D... choose malloc implementation [mallocng] + --with-malloc=3D... choose malloc implementation [mallocng] =20 Some influential environment variables: - CC C compiler command [detected] - CFLAGS C compiler flags [-Os -pipe ...] - CROSS_COMPILE prefix for cross compiler and tools [none] - LIBCC compiler runtime library [detected] + CC C compiler command [detected] + CFLAGS C compiler flags [-Os -pipe ...] + CROSS_COMPILE prefix for cross compiler and tools [none] + LIBCC compiler runtime library [detected] =20 Use these variables to override the choices made by configure. =20 @@ -143,6 +146,8 @@ wrapper=3Dauto gcc_wrapper=3Dno clang_wrapper=3Dno malloc_dir=3Dmallocng +frame_pointers=3Dno +unwind_tables=3Dnone =20 for arg ; do case "$arg" in @@ -172,6 +177,8 @@ case "$arg" in --disable-wrapper|--enable-wrapper=3Dno) wrapper=3Dno ;; --enable-gcc-wrapper|--enable-gcc-wrapper=3Dyes) wrapper=3Dyes ; = gcc_wrapper=3Dyes ;; --disable-gcc-wrapper|--enable-gcc-wrapper=3Dno) wrapper=3Dno ;; +--with-frame-pointers) frame_pointers=3Dyes ;; +--with-unwind-tables=3D*) unwind_tables=3D${arg#*=3D} ;; --with-malloc=3D*) malloc_dir=3D${arg#*=3D} ;; --enable-*|--disable-*|--with-*|--without-*|--*dir=3D*) ;; --host=3D*|--target=3D*) target=3D${arg#*=3D} ;; @@ -471,23 +478,46 @@ fi tryflag CFLAGS_AUTO -pipe =20 # -# If debugging is disabled, omit frame pointer. Modern GCC does this -# anyway on most archs even when debugging is enabled since the frame -# pointer is no longer needed for debugging. +# Unless otherwise specified, omit frame pointers where possible +# except when debugging is enabled. # -if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" ; then : +# In general, either frame pointers or unwind information are required +# if you wish to be able to obtain a reliable backtrace from a crashed +# program. +# +# Neither is required for debugging, as the full debug information +# will be used in that case. +# +if test "$frame_pointers" =3D yes ; then +tryflag CFLAGS_AUTO -fno-omit-frame-pointer +elif fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" ; then : else tryflag CFLAGS_AUTO -fomit-frame-pointer fi =20 # -# Modern GCC wants to put DWARF tables (used for debugging and -# unwinding) in the loaded part of the program where they are -# unstrippable. These options force them back to debug sections (and -# cause them not to get generated at all if debugging is off). +# Control the generation of unwind information. Note that this is not +# used for debugging; in C it is only used to allow runtime backtracing +# without frame pointers. In languages with exceptions, it is used to +# provide instructions to the unwinder (typically libunwind). # +case "$unwind_tables" in +none|no) tryflag CFLAGS_AUTO -fno-unwind-tables tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables +;; +sync|yes) +tryflag CFLAGS_AUTO -funwind-tables +tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables +;; +async) +tryflag CFLAGS_AUTO -funwind-tables +tryflag CFLAGS_AUTO -fasynchronous-unwind-tables +;; +*) +fail "$0: error: unknown unwind table settings '$unwind_tables'" +;; +esac =20 # # Attempt to put each function and each data object in its own