Skip to content

Commit

Permalink
Merge bitcoin#25697: depends: expat 2.4.8 & fix building with -flto
Browse files Browse the repository at this point in the history
e838a98 depends: re-enable using -flto when building expat (fanquake)
3044525 depends: expat 2.4.8 (fanquake)

Pull request description:

  Currently, when building the expat package in depends, using `-flto` (`LTO=1`), the configure check can fail, because it cannot determine the system endianess:
  ```bash
  configure:18718: result: unknown
  configure:18733: error: unknown endianness
   presetting ac_cv_c_bigendian=no (or yes) will help
  ```

  Fix that by defining `_DEFAULT_SOURCE`, which in turn defines `__USE_MISC` (`features.h`):
  ```c
  #if defined _DEFAULT_SOURCE
  # define __USE_MISC1
  #endif
  ```
  which exposes additional definitions in `endian.h`:
  ```c
  #include <features.h>

  /* Get the definitions of __*_ENDIAN, __BYTE_ORDER, and __FLOAT_WORD_ORDER.  */
  #include <bits/endian.h>

  #ifdef __USE_MISC
  # define LITTLE_ENDIAN__LITTLE_ENDIAN
  # define BIG_ENDIAN__BIG_ENDIAN
  # define PDP_ENDIAN__PDP_ENDIAN
  # define BYTE_ORDER__BYTE_ORDER
  #endif
  ```
  and gives us a working configure.

  You could test building this change with Guix + LTO with [this branch](https://github.com/fanquake/bitcoin/tree/lto_in_guix). Note that that build may fail for other reasons (on x86_64), unrelated to this change.

  Some related upstream discussion:
  https://bugs.gentoo.org/757681
  https://forums.gentoo.org/viewtopic-t-1013786.html

ACKs for top commit:
  hebasto:
    re-ACK e838a98, only [suggested](bitcoin#25697 (comment)) changes since my recent [review](bitcoin#25697 (review)).
  jarolrod:
    code review ACK e838a98

Tree-SHA512: 9dbf64c9bd1fd995a4d1addc011ffeff83d50df736030012346c97605e63aed4b5bac390a81abe646c1be28ad6fd600f64560dcb26bbc2edf5d513ca3b180bfa
  • Loading branch information
fanquake authored and PastaPastaPasta committed Feb 28, 2024
1 parent 587c335 commit a852a91
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions depends/packages/expat.mk
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package=expat
$(package)_version=2.4.1
$(package)_version=2.4.8
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_$(subst .,_,$($(package)_version))/
$(package)_file_name=$(package)-$($(package)_version).tar.xz
$(package)_sha256_hash=cf032d0dba9b928636548e32b327a2d66b1aab63c4f4a13dd132c2d1d2f2fb6a
$(package)_sha256_hash=f79b8f904b749e3e0d20afeadecf8249c55b2e32d4ebb089ae378df479dcaf25

# -D_DEFAULT_SOURCE defines __USE_MISC, which exposes additional
# definitions in endian.h, which are required for a working
# endianess check in configure when building with -flto.
define $(package)_set_vars
$(package)_config_opts=--disable-shared --without-docbook --without-tests --without-examples
$(package)_config_opts += --disable-dependency-tracking --enable-option-checking
$(package)_config_opts += --without-xmlwf
$(package)_config_opts_linux=--with-pic
$(package)_cflags += -fno-lto
$(package)_cppflags += -D_DEFAULT_SOURCE
endef

define $(package)_config_cmds
Expand Down

0 comments on commit a852a91

Please sign in to comment.