Skip to content

fix(build): initial rincoin-seeder bootstrap (glibc 2.38, rebrand, configs) - #2

Open
Aevust wants to merge 3 commits into
Rin-coin:masterfrom
Aevust:fix/strlcpy-glibc238
Open

fix(build): initial rincoin-seeder bootstrap (glibc 2.38, rebrand, configs)#2
Aevust wants to merge 3 commits into
Rin-coin:masterfrom
Aevust:fix/strlcpy-glibc238

Conversation

@Aevust

@Aevust Aevust commented Jun 11, 2026

Copy link
Copy Markdown

Changes

fix(build): gate bundled strlcpy/strlcat on glibc 2.38 and __USE_MISC

Fixes the build failure on glibc 2.38+ (Ubuntu 24.04 / glibc 2.39, g++ 13) caused by a collision between glibc's fortified inline declarations and the bundled strlcpy/strlcat fallback in strlcpy.h.


Root cause

glibc 2.38 (2023) added strlcpy/strlcat to libc, declared in <string.h> under __USE_MISC, with fortified definitions in <bits/string_fortified.h>. In a C++ build, libstdc++ defines _GNU_SOURCE, so __USE_MISC is active and glibc emits the declarations even under -std=c++11. Under the default _FORTIFY_SOURCE at -O3, those fortified inlines clash with the bundled plain inline copies, which carry no gnu_inline attribute:

strlcpy.h: error: 'size_t strlcpy(...)' redeclared inline without 'gnu_inline' attribute

Fix

Define an internal HAVE_LIBC_STRLCPY flag and compile the bundled copies only when it is unset. The flag is set through a two-level guard:

#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
#  if __GLIBC_PREREQ(2, 38) && defined(__USE_MISC)
#    define HAVE_LIBC_STRLCPY 1
#  endif
#endif
  • The outer defined(__GLIBC__) && defined(__GLIBC_PREREQ) keeps the preprocessor from evaluating the function-like __GLIBC_PREREQ macro on non-glibc toolchains (musl, *BSD, MinGW), where it is undefined and #if __GLIBC_PREREQ(...) would be ill-formed. On those platforms the flag stays unset and the bundled fallback is compiled, preserving prior behavior.
  • The inner __GLIBC_PREREQ(2, 38) && defined(__USE_MISC) matches the exact condition under which glibc declares strlcpy/strlcat (≥ 2.38 with __USE_MISC active), so a strict build that does not pull in glibc's declaration still gets the fallback.

__GLIBC_USE(LIB_EXT2) is unsuitable as the guard: it is enabled by _GNU_SOURCE and therefore always true in this C++ build, which would skip the bundled fallback even on glibc < 2.38 and cause an undefined reference at link time. The bundled function bodies and the third-party BSD header are unchanged.

The same root cause exists in upstream sipa/bitcoin-seeder; the fix has been shared on the related upstream issue as an individual contribution: sipa/bitcoin-seeder, issue 109.


chore: rebrand bitcoin-seeder to rincoin-seeder

Adapts the upstream bitcoin-seeder for the Rincoin network:

  • Renames bitcoin.cpp/bitcoin.h to rincoin.cpp/rincoin.h and updates the seed nonce and include guards accordingly.
  • Sets Rincoin network parameters: default P2P port 9555, seed host seed.rincoin.org, and version string /rincoin-seeder:1.0.0/.
  • Adds a top-level COPYING (MIT) and per-file copyright headers crediting The Rincoin Core developers while preserving attribution to bitcoin-seeder by Pieter Wuille (sipa).
  • Updates README, Makefile, combine.pl, and test.pl for the Rincoin network.

chore: add .editorconfig and .gitattributes

Enforces LF line endings, UTF-8 charset, final newline, and trailing-whitespace trimming across the repository. .gitattributes handles normalization at the Git layer for consistency across the Windows and Ubuntu build workflow. Makefile is explicitly preserved with tab indentation to avoid build failures.


Testing

  • make clean && make on Ubuntu 24.04 (glibc 2.39, g++ 13) — redeclared inline error absent, dnsseed binary produced
  • No undefined reference to strlcpy/strlcat linker errors
  • dnsseed starts and resolves queries on test port
Build & smoke test — Ubuntu 24.04 (glibc 2.39, g++ 13) — 2026-06-08

Build (make clean && make):

g++ -std=c++11 -pthread -O3 -g0 -march=native -Wall ... -c -o dns.o dns.cpp
g++ ... -c -o rincoin.o rincoin.cpp
g++ ... -c -o netbase.o netbase.cpp
g++ ... -c -o protocol.o protocol.cpp
g++ ... -c -o db.o db.cpp
g++ ... -c -o main.o main.cpp
g++ ... -c -o util.o util.cpp
g++ -pthread -O3 -g0 -march=native -o dnsseed dns.o rincoin.o netbase.o protocol.o db.o main.o util.o -lcrypto

No redeclared inline errors. No undefined reference linker errors. dnsseed binary produced.

Smoke test (test port, ~4 min):

Starting 4 DNS threads for seed.rincoin.org on ns.example.com (port 15353)...done
Starting seeder...done
Starting 96 crawler threads...done
[26-06-08 14:35:34] 2/18 available (2 tried in 1s, 9 new, 7 active), 0 banned; 0 DNS requests, 0 db queries
[26-06-08 14:37:03] 7/26 available (26 tried in 90s, 0 new, 0 active), 0 banned; 1 DNS requests, 1 db queries

DNS resolution (dig @127.0.0.1 -p 15353 A seed.rincoin.org):

;; status: NOERROR, ANSWER: 3

;; ANSWER SECTION:
seed.rincoin.org.   3600  IN  A  46.250.xxx.xxx
seed.rincoin.org.   3600  IN  A  185.153.xxx.xxx
seed.rincoin.org.   3600  IN  A  85.131.xxx.xxx

;; Query time: 0 msec
;; WHEN: Mon Jun 08 14:37:03 JST 2026

3 A records returned from available pool (7/26). Query time 0 ms (UDP).


Provenance

GPG-signed development commit:
Aevust/rincoin-seeder/commit/b7a23c7a0cba02576863aa78179328affaeb95b7

Aevust added 3 commits June 6, 2026 20:21
  Rename bitcoin.{h,cpp} to rincoin.{h,cpp} and update include
  guards (netbase/compat/serialize/uint256/strlcpy) from the
  BITCOIN_ prefix to RINCOIN_. Add Rincoin Core copyright
  headers across the source files and unify the license
  reference to the in-repo COPYING file.

  Advertise the subversion string /rincoin-seeder:1.0.0/ in the
  version handshake, matching the current v1 generation. The
  seed nonce value is unchanged; only its macro name is updated.
  Fix the combine.pl address filter to match the Rincoin P2P
  port 9555 instead of Bitcoin's 8333, and point test.pl at the
  Rincoin seed zone.

  No protocol behaviour changes: PROTOCOL_VERSION (60000), magic
  bytes (RINC) and default ports (9555/19555) are left as-is. The
  70018 customized-halving bump is deferred pending the Core/RIP
  decision.
Enforce LF line endings, UTF-8 charset, final newline, and
trailing-whitespace trimming across the repository. Makefile is
explicitly preserved with tab indentation to avoid build
failures. .gitattributes enforces LF at the Git layer, so checkouts
remain consistent across the Windows and Ubuntu workflow.
The previous guard keyed on __GLIBC_USE(LIB_EXT2), which is enabled
by _GNU_SOURCE and therefore always true in the C++ build, regardless
of the glibc version. On glibc < 2.38, that skipped the bundled
fallback even though libc does not provide strlcpy/strlcat there,
leaving an undefined reference at link time.

Key the fallback on __GLIBC_PREREQ(2, 38) together with __USE_MISC,
the exact condition under which glibc declares these functions, and
keep the bundled copies as plain inline definitions. This builds on
glibc >= 2.38 (libc provides them), on glibc < 2.38 (bundled
fallback), and on non-glibc libcs, without weakening _FORTIFY_SOURCE.

Drop the gnu_inline attribute: with this guard, the bundled and libc
definitions never coexist, and plain C++ inline avoids an undefined
reference when the fallback is the only definition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant