build: Windows DLL additions #1022

pull fanquake wants to merge 2 commits into bitcoin-core:master from fanquake:windll_additions changing 2 files +2 −1
  1. fanquake commented at 5:20 AM on December 2, 2021: member

    This takes care of two of the outstanding issues in #923. One being initializing libtool with win32-dll and the other being the addition of -no-undefined to the libtool LDFLAGS. See each commit for more details.

    Builders cross-compiling for Windows (including Core) will no-longer see:

    libtool: warning: undefined symbols not allowed in x86_64-w64-mingw32 shared libraries; building static only
    

    I'm planning on making some related changes downstream.

  2. build: pass win32-dll to LT_INIT
    This is the recommended way to support building PE DLLs with modern
    mingw toolchains and libtool.
    
    > This option should be used if the package has been ported to build clean
    > dlls on win32 platforms.
    > If this macro is not used, libtool will assume that the package libraries
    > are not dll clean and will build only static libraries on win32 hosts.
    
    See:
    https://www.gnu.org/software/libtool/manual/libtool.html#LT_005fINIT
    https://www.gnu.org/software/gnulib/manual/html_node/Libtool-and-Windows.html
    https://autotools.io/libtool/windows.html
    fe32a79d35
  3. build: add -no-undefined to libtool LDFLAGS
    Instruct libtool to not allow undefined symbols when linking a shared
    library.
    
    See:
    https://autotools.io/libtool/windows.html
    https://www.gnu.org/software/libtool/manual/libtool.html#LT_005fINIT
    https://www.gnu.org/software/gnulib/manual/html_node/Libtool-and-Windows.html
    c0cd7de6d4
  4. real-or-random approved
  5. real-or-random commented at 11:08 AM on December 2, 2021: contributor

    Thanks !

    ACK c0cd7de6d4e497c0e678f7098079727188e81de8

    This fits what I said in in #923.

  6. hebasto commented at 1:29 PM on December 3, 2021: member

    Concept ACK.

  7. hebasto approved
  8. hebasto commented at 3:18 PM on December 4, 2021: member

    ACK c0cd7de6d4e497c0e678f7098079727188e81de8

    The first commit (fe32a79d354dfc7f341dbfdd6b8f0d408bd76e5b) makes LT_INIT macro perform more checks:

     checking for stdint.h... yes
     checking for unistd.h... yes
     checking for dlfcn.h... no
    +checking for x86_64-w64-mingw32-as... x86_64-w64-mingw32-as
    +checking for x86_64-w64-mingw32-dlltool... (cached) x86_64-w64-mingw32-dlltool
    +checking for x86_64-w64-mingw32-objdump... (cached) x86_64-w64-mingw32-objdump
     checking for objdir... .libs
     checking if x86_64-w64-mingw32-gcc supports -fno-rtti -fno-exceptions... no
     checking for x86_64-w64-mingw32-gcc option to produce PIC... -DDLL_EXPORT -DPIC
    

    The second commit (c0cd7de6d4e497c0e678f7098079727188e81de8) makes Automake+Libtool build .libs/libsecp256k1-0.dll for --host=x86_64-w64-mingw32:

    • on the build machine:
    $ x86_64-w64-mingw32-nm -u .libs/libsecp256k1-0.dll 
                     U __end__
    
    • on the host machine (Windows 10 Pro 21H1):
    >dumpbin /exports C:\Users\hebasto\Desktop\libsecp256k1-0.dll
    Microsoft (R) COFF/PE Dumper Version 14.28.29913.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    
    Dump of file C:\Users\hebasto\Desktop\libsecp256k1-0.dll
    
    File Type: DLL
    
      Section contains the following exports for libsecp256k1-0.dll
    
        00000000 characteristics
        61AB733A time date stamp Sat Dec  4 15:55:06 2021
            0.00 version
               1 ordinal base
              39 number of functions
              39 number of names
    
        ordinal hint RVA      name
    
              1    0 0000DCD0 secp256k1_context_clone
              2    1 0000DB70 secp256k1_context_create
              3    2 0000DE20 secp256k1_context_destroy
              4    3 00014010 secp256k1_context_no_precomp
              5    4 0000DBE0 secp256k1_context_preallocated_clone
              6    5 0000DA00 secp256k1_context_preallocated_clone_size
              7    6 0000DA10 secp256k1_context_preallocated_create
              8    7 0000DD20 secp256k1_context_preallocated_destroy
              9    8 0000D9D0 secp256k1_context_preallocated_size
             10    9 00012130 secp256k1_context_randomize
             11    A 0000DEB0 secp256k1_context_set_error_callback
             12    B 0000DE50 secp256k1_context_set_illegal_callback
             13    C 000118C0 secp256k1_ec_privkey_negate
             14    D 00011B30 secp256k1_ec_privkey_tweak_add
             15    E 00011EA0 secp256k1_ec_privkey_tweak_mul
             16    F 00010430 secp256k1_ec_pubkey_cmp
             17   10 00012150 secp256k1_ec_pubkey_combine
             18   11 000116A0 secp256k1_ec_pubkey_create
             19   12 000118D0 secp256k1_ec_pubkey_negate
             20   13 0000DFF0 secp256k1_ec_pubkey_parse
             21   14 00010260 secp256k1_ec_pubkey_serialize
             22   15 00011B40 secp256k1_ec_pubkey_tweak_add
             23   16 00011EB0 secp256k1_ec_pubkey_tweak_mul
             24   17 00011820 secp256k1_ec_seckey_negate
             25   18 00011A00 secp256k1_ec_seckey_tweak_add
             26   19 00011D80 secp256k1_ec_seckey_tweak_mul
             27   1A 00011660 secp256k1_ec_seckey_verify
             28   1B 00010E20 secp256k1_ecdsa_sign
             29   1C 00010C20 secp256k1_ecdsa_signature_normalize
             30   1D 000106A0 secp256k1_ecdsa_signature_parse_compact
             31   1E 00010540 secp256k1_ecdsa_signature_parse_der
             32   1F 00010B80 secp256k1_ecdsa_signature_serialize_compact
             33   20 000107C0 secp256k1_ecdsa_signature_serialize_der
             34   21 00010CE0 secp256k1_ecdsa_verify
             35   22 00015480 secp256k1_nonce_function_default
             36   23 00015488 secp256k1_nonce_function_rfc6979
             37   24 0000DF10 secp256k1_scratch_space_create
             38   25 0000DF80 secp256k1_scratch_space_destroy
             39   26 00012380 secp256k1_tagged_sha256
    
      Summary
    
            1000 .CRT
            1000 .bss
            1000 .data
            3000 .debug_abbrev
            1000 .debug_aranges
            3000 .debug_frame
           4A000 .debug_info
            E000 .debug_line
           29000 .debug_loc
            9000 .debug_ranges
            1000 .debug_str
            1000 .edata
            1000 .idata
            1000 .pdata
          111000 .rdata
            1000 .reloc
           13000 .text
            1000 .tls
            1000 .xdata
    

    Builders cross-compiling for Windows (including Core) will no-longer see:

    libtool: warning: undefined symbols not allowed in x86_64-w64-mingw32 shared libraries; building static only
    

    The warning vanished because a shared library is being built now.

  9. sipa commented at 3:52 PM on December 4, 2021: contributor

    utACK c0cd7de6d4e497c0e678f7098079727188e81de8. We indeed have done the work to propertly mark exported symbols, and AFAIK have no imported symbols apart from standard library ones.

  10. hebasto commented at 3:53 PM on December 4, 2021: member

    FWIW, with CPPFLAGS='-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC' linking the bench.exe fails now:

      CCLD     bench.exe
    libtool:   error: Could not determine the host path corresponding to
    libtool:   error:   '/home/hebasto/GitHub/secp256k1/.libs'
    libtool:   error: Continuing, but uninstalled executables may not work.
    libtool:   error: Could not determine the host path corresponding to
    libtool:   error:   '/home/hebasto/GitHub/secp256k1/.libs:/usr/local/lib:/usr/local/bin'
    libtool:   error: Continuing, but uninstalled executables may not work.
    
  11. real-or-random commented at 10:16 AM on December 5, 2021: contributor

    FWIW, with CPPFLAGS='-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC' linking the bench.exe fails now:

    I had to look those up. Just for my understanding, are you suggesting that's a problem? I think if people need this, they can still override LDFLAGS.

  12. hebasto commented at 10:50 AM on December 5, 2021: member

    No, it's not a blocker for this pr which is correct.

    On Sun, 5 Dec 2021 at 12:16, Tim Ruffing @.***> wrote:

    FWIW, with CPPFLAGS='-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC' linking the bench.exe fails now:

    I had to look those up. Just for my understanding, are you suggesting that's a problem? I think if people need this, they can still override LDFLAGS.

    — You are receiving this because you commented.

    Reply to this email directly, view it on GitHub https://github.com/bitcoin-core/secp256k1/pull/1022#issuecomment-986202616, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH3PXPTOSWDGXVUQRB3QZ4DUPM3ZVANCNFSM5JGGOXIQ .

    --

    -- Hennadii Stepanov

  13. real-or-random merged this on Dec 5, 2021
  14. real-or-random closed this on Dec 5, 2021

  15. hebasto commented at 5:47 PM on December 5, 2021: member

    FWIW, with CPPFLAGS='-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC' linking the bench.exe fails now:

    I had to look those up. Just for my understanding, are you suggesting that's a problem? I think if people need this, they can still override LDFLAGS.

    Not related to this PR (as it looks), but I'm curious why libstdc++ flags affect C code?

  16. fanquake deleted the branch on Dec 6, 2021
  17. real-or-random commented at 8:26 AM on December 6, 2021: contributor

    Not related to this PR (as it looks), but I'm curious why libstdc++ flags affect C code?

    No idea, but if you're interested you could look at the diff of the preprocessor output with and without the flags. Maybe that will explain it.

  18. sipa referenced this in commit 86dbc4d075 on Dec 15, 2021
  19. sipa cross-referenced this on Dec 15, 2021 from issue Update libsecp256k1 subtree to current master by sipa
  20. jonasnick cross-referenced this on Jan 2, 2022 from issue Sync Upstream by jonasnick
  21. real-or-random referenced this in commit 21e2d65b79 on Jan 5, 2022
  22. fanquake referenced this in commit 2de1025390 on Jan 20, 2022
  23. fanquake cross-referenced this on Jan 20, 2022 from issue build: pass win32-dll to LT_INIT() by fanquake
  24. fanquake referenced this in commit eb2db6d1f2 on Feb 17, 2022
  25. fanquake referenced this in commit 80e78b6a04 on Feb 22, 2022
  26. fanquake referenced this in commit 5a8d56680b on Feb 23, 2022
  27. sidhujag referenced this in commit 4e6b8dbdc9 on Feb 23, 2022
  28. PastaPastaPasta referenced this in commit 99e5e02feb on Apr 7, 2022
  29. PastaPastaPasta referenced this in commit 55bd901c7f on Apr 11, 2022
  30. div72 referenced this in commit d6c76955ae on May 18, 2022
  31. gwillen referenced this in commit 35d6112a72 on May 25, 2022
  32. gades referenced this in commit 3af73f4de1 on Jun 19, 2022
  33. hebasto cross-referenced this on Jul 5, 2022 from issue build: Link `bench` binary statically by hebasto
  34. janus referenced this in commit 879a9a27b9 on Jul 10, 2022
  35. janus referenced this in commit b19b245df3 on Jul 24, 2022
  36. patricklodder referenced this in commit 21badcf9d2 on Jul 25, 2022
  37. patricklodder referenced this in commit 03002a9013 on Jul 28, 2022
  38. backpacker69 referenced this in commit 77186f4a04 on Jan 18, 2023
  39. backpacker69 referenced this in commit 038b7ee1ef on Jan 18, 2023
  40. str4d referenced this in commit 6de4698bf9 on Apr 21, 2023
  41. vmta referenced this in commit e1120c94a1 on Jun 4, 2023
  42. vmta referenced this in commit 8f03457eed on Jul 1, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 22:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me