Ramips rt305x and mt7620 pppd causing issues at build

In my build environment I have several profiles for ramips that I want to build one after each other.

  • rt305x
  • mt7620
  • mt7621
  • mt76x8
    These execute in order, and the build environment is not cleaned between them. In general (amongst other targets) this works fine.
    In this specific case, building rt305x first results in the others failing to compile pppd with the following errors:
cd pppd; make -w all
make[6]: Entering directory '/home/michael/gargoyle115/gargoyle/ramips-src/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/ppp-default/ppp-2.4.9.git-2021-01-04/pppd'
mipsel-openwrt-linux-musl-gcc -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -fmacro-prefix-map=/home/michael/gargoyle115/gargoyle/ramips-src/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/ppp-default/ppp-2.4.9.git-2021-01-04=ppp-2.4.9.git-2021-01-04 -Wformat -Werror=format-security -DPIC -fpic -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -ffunction-sections -fdata-sections -flto -DHAVE_PATHS_H -DHAVE_MMAP -pipe -I../include '-DDESTDIR="/usr"' -DCHAPMS=1 -DMPPE=1 -DHAS_SHADOW -DHAVE_CRYPT_H=1 -DUSE_CRYPT=1 -DPLUGIN -DPPP_FILTER -DPPP_PRECOMPILED_FILTER -I/home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/target-mipsel_24kc_musl/usr/include -DINET6=1 -DMAXOCTETS -L/home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/toolchain-mipsel_24kc_gcc-11.2.0_musl/usr/lib -L/home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/toolchain-mipsel_24kc_gcc-11.2.0_musl/lib -DPIC -fpic -specs=/home/michael/gargoyle115/gargoyle/ramips-src/include/hardened-ld-pie.specs -znow -zrelro -Wl,--gc-sections -flto -fuse-linker-plugin  -Wl,-E -o pppd main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o eap.o chap-md5.o session.o md4.o chap_ms.o sha1.o pppcrypt.o pcap_pcc.o ipv6cp.o eui64.o -lrt -lcrypt -ldl /home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/target-mipsel_24kc_musl/usr/lib/libpcap.a
/home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/target-mipsel_24kc_musl/usr/lib/libpcap.a(bpf_filter.c.o): in function `__jend_pcap_filter_with_aux_data_8':
bpf_filter.c:(.text+0x140): relocation R_MIPS16_26 against `abort' cannot be used when making a shared object; recompile with -fPIC
bpf_filter.c:(.text+0x1be): relocation R_MIPS16_26 against `ntohl' cannot be used when making a shared object; recompile with -fPIC
bpf_filter.c:(.text+0x1e2): relocation R_MIPS16_26 against `ntohs' cannot be used when making a shared object; recompile with -fPIC
/home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/target-mipsel_24kc_musl/usr/lib/libpcap.a(bpf_filter.c.o): in function `pcap_filter':
bpf_filter.c:(.text+0x384): relocation R_MIPS16_26 against `pcap_filter_with_aux_data' cannot be used when making a shared object; recompile with -fPIC
/home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/target-mipsel_24kc_musl/usr/lib/libpcap.a(bpf_filter.c.o): in function `bpf_filter':
bpf_filter.c:(.text+0x482): relocation R_MIPS16_26 against `pcap_filter' cannot be used when making a shared object; recompile with -fPIC
/home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/target-mipsel_24kc_musl/usr/lib/libpcap.a(bpf_filter.c.o): in function `bpf_validate':
bpf_filter.c:(.text+0x48e): relocation R_MIPS16_26 against `pcap_validate_filter' cannot be used when making a shared object; recompile with -fPIC
/home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/toolchain-mipsel_24kc_gcc-11.2.0_musl/lib/gcc/mipsel-openwrt-linux-musl/11.2.0/../../../../mipsel-openwrt-linux-musl/bin/ld: non-dynamic relocations refer to dynamic symbol abort
/home/michael/gargoyle115/gargoyle/ramips-src/staging_dir/toolchain-mipsel_24kc_gcc-11.2.0_musl/lib/gcc/mipsel-openwrt-linux-musl/11.2.0/../../../../mipsel-openwrt-linux-musl/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[6]: *** [Makefile:259: pppd] Error 1
make[6]: Leaving directory '/home/michael/gargoyle115/gargoyle/ramips-src/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/ppp-default/ppp-2.4.9.git-2021-01-04/pppd'
make[5]: *** [Makefile:15: all] Error 2
make[5]: Leaving directory '/home/michael/gargoyle115/gargoyle/ramips-src/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/ppp-default/ppp-2.4.9.git-2021-01-04'
make[4]: *** [Makefile:305: /home/michael/gargoyle115/gargoyle/ramips-src/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/ppp-default/ppp-2.4.9.git-2021-01-04/.built] Error 2
make[4]: Leaving directory '/home/michael/gargoyle115/gargoyle/ramips-src/package/network/services/ppp'
time: package/network/services/ppp/default/compile#3.20#0.14#3.28
    ERROR: package/network/services/ppp failed to build (build variant: default).
make[3]: *** [package/Makefile:116: package/network/services/ppp/compile] Error 1

I haven't noticed any other packages failing in this manner (but it bombs out the build so there may be others I've not run into). A clean compile of that package OR cleaning the build environment and building the other profiles works as expected.

My questions:

  1. Is my method of building the other profiles within the same build environment supposed to work, or am I doing something unsupported/unadvised?
  2. Can I force pppd (or libpcap) to rebuild somehow between profile runs (or at least incompatible ones)? (note that this is a scripted build, but I could work something in)
  3. Is the pppd makefile (or libpcap) missing something (like the -fPIC switch) that would cause this and I've just stumbled onto it?

I'm currently running a test if building mt76xx before rt305x behaves any better but won't know for a few hours.
Any guidance appreciated thanks

Confirming that building mt7620 first, then rt305x completes fine.

build MT76X8 a similar issue:
/openwrt/staging_dir/toolchain-mipsel_24kc_gcc-13.2.0_musl/lib/gcc/mipsel-openwrt-linux-musl/13.2.0/../../../../mipsel-openwrt-linux-musl/bin/ld.bfd: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[5]: *** [objs/Makefile:1325: objs/ngx_http_ubus_module.so] Error 1
not found a solution