To: [email protected]
Subject:ld.lld linker errors with aspell on mips64el even with 7.8 updated
toolchain
From: [email protected]
Cc: [email protected]
Reply-To:[email protected]
>Synopsis: libsodium fails to build on OpenBSD/mips64 due to undefined
>PAGE_SHIFT and PAGE_SIZE macros
>Category: ports
>Environment:
System : OpenBSD 7.8
Details : OpenBSD 7.8 (GENERIC) #89: Thu Oct 9 11:13:45 GMT 2025
[email protected]:/usr/src/sys/arch/loongson/compile/GENERIC
Architecture: OpenBSD.loongson
Machine : loongson
>Description:
The security/libsodium port fails to compile on OpenBSD 7.8 for mips64el
(loongson) architecture.
During compilation, the following error occurs:
/usr/ports/pobj/libsodium-1.0.20/libsodium-1.0.20/src/libsodium/sodium/utils.c:104:34:
error: use of undeclared identifier 'PAGE_SHIFT'
104 | static size_t page_size = DEFAULT_PAGE_SIZE;
| ^
/usr/ports/pobj/libsodium-1.0.20/libsodium-1.0.20/src/libsodium/sodium/utils.c:98:29:
note: expanded from macro 'DEFAULT_PAGE_SIZE'
98 | # define DEFAULT_PAGE_SIZE PAGE_SIZE
| ^
/usr/include/mips64/param.h:44:25: note: expanded from macro 'PAGE_SIZE'
44 | #define PAGE_SIZE (1 << PAGE_SHIFT)
| ^
The root cause is that on OpenBSD/mips64 (loongson), the system headers do not
define `PAGE_SHIFT` in all contexts where `PAGE_SIZE` is used. The libsodium
code indirectly uses `PAGE_SIZE` via its `DEFAULT_PAGE_SIZE` macro, which
expands to `(1 << PAGE_SHIFT)`, but `PAGE_SHIFT` is not defined, causing the
compilation error.
Additionally, the actual page size on this loongson machine is 16KB (16384
bytes), as confirmed by `sysctl hw.pagesize = 16384`, not the typical 4KB or
8KB.
>How-To-Repeat:
1. On an OpenBSD 7.8 loongson (mips64el) system:
cd /usr/ports/security/libsodium
2. Attempt to build:
make
3. Observe the compilation error regarding undefined `PAGE_SHIFT`.
>Fix:
A working workaround is to modify
`/usr/ports/pobj/libsodium-1.0.20/libsodium-1.0.20/src/libsodium/sodium/utils.c`
by adding a platform-specific definition:
Replace the DEFAULT_PAGE_SIZE definition block (around line 98) with:
#ifndef DEFAULT_PAGE_SIZE
if defined(OpenBSD) && defined(mips64)
define DEFAULT_PAGE_SIZE 16384 /* 16KB for OpenBSD/mips64 */
elif defined(PAGE_SIZE)
define DEFAULT_PAGE_SIZE PAGE_SIZE
else
define DEFAULT_PAGE_SIZE 0x10000
endif
#endif
For a proper port fix, the libsodium port should either:
1. Detect OpenBSD/mips64 and hardcode the correct page size, or
2. Use `sysconf(_SC_PAGESIZE)` instead of relying on the `PAGE_SIZE` macro
which depends on the undefined `PAGE_SHIFT` on this platform.
SENDBUG: dmesg, pcidump, acpidump and usbdevs are attached.
SENDBUG: Feel free to delete or use the -D flag if they contain sensitive
information.
dmesg:
OpenBSD 7.8 (GENERIC) #89: Thu Oct 9 11:13:45 GMT 2025
[email protected]:/usr/src/sys/arch/loongson/compile/GENERIC
real mem = 1073741824 (1024MB)
avail mem = 1051803648 (1003MB)
random: good seed from bootblocks
mainbus0 at root: Lemote Lynloong
cpu0 at mainbus0: STC Loongson2F CPU 800 MHz, STC Loongson2F FPU
cpu0: cache L1-I 64KB D 64KB 4 way, L2 512KB 4 way
bonito0 at mainbus0: memory and PCI-X controller, rev 1
pci0 at bonito0 bus 0
rl0 at pci0 dev 6 function 0 "Realtek 8139" rev 0x10: irq 4, address
00:23:9e:00:71:c5
rlphy0 at rl0 phy 0: RTL internal PHY
sisfb0 at pci0 dev 8 function 0 "SiS 315 Pro VGA" rev 0x00: 1360x768, 16bpp
wsdisplay0 at sisfb0 mux 1: console (std, vt100 emulation)
glxpcib0 at pci0 dev 14 function 0 "AMD CS5536 ISA" rev 0x03: rev 3, 32-bit
3579545Hz timer, watchdog, gpio, i2c
isa0 at glxpcib0
mcclock0 at isa0 port 0x70/2: mc146818 or compatible
gpio1 at glxpcib0: 32 pins
iic1 at glxpcib0
spdmem0 at iic1 addr 0x50: 1GB DDR2 SDRAM non-parity PC2-5300CL5 SO-DIMM
glxclk0 at glxpcib0
pciide0 at pci0 dev 14 function 2 "AMD CS5536 IDE" rev 0x01: DMA, channel 0
wired to compatibility, channel 1 wired to compatibility
wd0 at pciide0 channel 0 drive 0: <SAMSUNG HM161HI>
wd0: 16-sector PIO, LBA48, 152627MB, 312581808 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
pciide0: channel 1 ignored (disabled)
auglx0 at pci0 dev 14 function 3 "AMD CS5536 Audio" rev 0x01: isa irq 9, CS5536
AC97
ac97: codec id 0x414c4760 (Avance Logic ALC655 rev 0)
audio0 at auglx0
ohci0 at pci0 dev 14 function 4 "AMD CS5536 USB" rev 0x02: isa irq 11, version
1.0, legacy support
ehci0 at pci0 dev 14 function 5 "AMD CS5536 USB" rev 0x02: isa irq 11
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "AMD EHCI root hub" rev 2.00/1.00
addr 1
usb1 at ohci0: USB revision 1.0
uhub1 at usb1 configuration 1 interface 0 "AMD OHCI root hub" rev 1.00/1.00
addr 1
apm0 at mainbus0
vscsi0 at root
scsibus0 at vscsi0: 256 targets
softraid0 at root
scsibus1 at softraid0: 256 targets
pmon bootpath: bootduid=0c5a85b50bd214cd
root on wd0a (0c5a85b50bd214cd.a) swap on wd0b dump on wd0b
usbdevs:
Controller /dev/usb0:
addr 01: 1022:0000 AMD, EHCI root hub
high speed, self powered, config 1, rev 1.00
driver: uhub0
Controller /dev/usb1:
addr 01: 1022:0000 AMD, OHCI root hub
full speed, self powered, config 1, rev 1.00
driver: uhub1
pcidump:
Domain /dev/pci0:
0:6:0: Realtek 8139
0x0000: Vendor ID: 10ec, Product ID: 8139
0x0004: Command: 0147, Status: 0290
0x0008: Class: 02 Network, Subclass: 00 Ethernet,
Interface: 00, Revision: 10
0x000c: BIST: 00, Header Type: 00, Latency Timer: 40,
Cache Line Size: 00
0x0010: BAR io addr: 0x0000b100/0x0100
0x0014: BAR mem 32bit addr: 0x04055000/0x00000100
0x0018: BAR empty (00000000)
0x001c: BAR empty (00000000)
0x0020: BAR empty (00000000)
0x0024: BAR empty (00000000)
0x0028: Cardbus CIS: 00000000
0x002c: Subsystem Vendor ID: 10ec Product ID: 8139
0x0030: Expansion ROM Base Address: 00000000
0x0038: 00000000
0x003c: Interrupt Pin: 01 Line: 00 Min Gnt: 20 Max Lat: 40
0x0050: Capability 0x01: Power Management
State: D0
0x0000: 813910ec 02900147 02000010 00004000
0x0010: 0000b101 04055000 00000000 00000000
0x0020: 00000000 00000000 00000000 813910ec
0x0030: 00000000 00000050 00000000 40200100
0x0040: 00000000 00000000 00000000 00000000
0x0050: f7c20001 00000000 00000000 00000000
0x0060: 00000000 00000000 00000000 00000000
0x0070: 00000000 00000000 00000000 00000000
0x0080: 00000000 00000000 00000000 00000000
0x0090: 00000000 00000000 00000000 00000000
0x00a0: 00000000 00000000 00000000 00000000
0x00b0: 00000000 00000000 00000000 00000000
0x00c0: 00000000 00000000 00000000 00000000
0x00d0: 00000000 00000000 00000000 00000000
0x00e0: 00000000 00000000 00000000 00000000
0x00f0: 00000000 00000000 00000000 00000000
0:8:0: SiS 315 Pro VGA
0x0000: Vendor ID: 1039, Product ID: 0325
0x0004: Command: 0007, Status: 0230
0x0008: Class: 03 Display, Subclass: 00 VGA,
Interface: 00, Revision: 00
0x000c: BIST: 80, Header Type: 00, Latency Timer: 47,
Cache Line Size: 00
0x0010: BAR mem prefetchable 32bit addr: 0x40000000/0x10000000
0x0014: BAR mem 32bit addr: 0x04000000/0x00040000
0x0018: BAR io addr: 0x0000b300/0x0080
0x001c: BAR empty (00000000)
0x0020: BAR empty (00000000)
0x0024: BAR empty (00000000)
0x0028: Cardbus CIS: 00000000
0x002c: Subsystem Vendor ID: 3030 Product ID: 3030
0x0030: Expansion ROM Base Address: 04040001
0x0038: 00000000
0x003c: Interrupt Pin: 01 Line: 00 Min Gnt: 03 Max Lat: 10
0x0040: Capability 0x01: Power Management
State: D0
0x0000: 03251039 02300007 03000000 80004700
0x0010: 40000008 04000000 0000b301 00000000
0x0020: 00000000 00000000 00000000 30303030
0x0030: 04040001 00000040 00000000 10030100
0x0040: 06020001 00000000 00000000 00000000
0x0050: 00100002 0f000201 00000000 00000000
0x0060: 00000000 00000000 00000000 00000000
0x0070: 00000000 00000000 00000000 00000000
0x0080: 00000000 00000000 00000000 00000000
0x0090: 00000000 00000000 00000000 00000000
0x00a0: 00000000 00000000 00000000 00000000
0x00b0: 00000000 00000000 00000000 00000000
0x00c0: 00000000 00000000 00000000 00000000
0x00d0: 00000000 00000000 00000000 00000000
0x00e0: 00000000 00000000 00000000 00000000
0x00f0: 00000000 00000000 00000000 00000000
0:14:0: AMD CS5536 ISA
0x0000: Vendor ID: 1022, Product ID: 2090
0x0004: Command: 0045, Status: 02a0
0x0008: Class: 06 Bridge, Subclass: 01 ISA,
Interface: 00, Revision: 03
0x000c: BIST: 00, Header Type: 80, Latency Timer: 40,
Cache Line Size: 08
0x0010: BAR io addr: 0x0000b410/0x0008
0x0014: BAR io addr: 0x0000b000/0x0100
0x0018: BAR io addr: 0x0000b380/0x0040
0x001c: BAR io addr: 0x0000b3e0/0x0020
0x0020: BAR io addr: 0x0000b280/0x0080
0x0024: BAR io addr: 0x0000b3c0/0x0020
0x0028: Cardbus CIS: 00000000
0x002c: Subsystem Vendor ID: 1022 Product ID: 2090
0x0030: Expansion ROM Base Address: 00000000
0x0038: 00000000
0x003c: Interrupt Pin: 00 Line: 00 Min Gnt: 00 Max Lat: 40
0x0000: 20901022 02a00045 06010003 00804008
0x0010: 0000b411 0000b001 0000b381 0000b3e1
0x0020: 0000b281 0000b3c1 00000000 20901022
0x0030: 00000000 00000000 00000000 40000000
0x0040: 00000000 00000000 00000000 00000000
0x0050: 00000000 00000000 00000000 00000000
0x0060: 00000000 00000000 00000000 00000000
0x0070: 00000000 00000000 00000000 00000000
0x0080: 00000000 00000000 00000000 00000000
0x0090: 00000000 00000000 00000000 00000000
0x00a0: 00000000 00000000 00000000 00000000
0x00b0: 00000000 00000000 00000000 00000000
0x00c0: 00000000 00000000 00000000 00000000
0x00d0: 00000000 00000000 00000000 00000000
0x00e0: 00000000 00000000 00000000 00000000
0x00f0: 00000001 8000000e 0000b3c0 0000f001
0:14:2: AMD CS5536 IDE
0x0000: Vendor ID: 1022, Product ID: 209a
0x0004: Command: 0045, Status: 02a0
0x0008: Class: 01 Mass Storage, Subclass: 01 IDE,
Interface: 80, Revision: 01
0x000c: BIST: 00, Header Type: 00, Latency Timer: 40,
Cache Line Size: 08
0x0010: BAR empty (00000000)
0x0014: BAR empty (00000000)
0x0018: BAR empty (00000000)
0x001c: BAR empty (00000000)
0x0020: BAR io addr: 0x0000b400/0x0010
0x0024: BAR empty (00000000)
0x0028: Cardbus CIS: 00000000
0x002c: Subsystem Vendor ID: 1022 Product ID: 209a
0x0030: Expansion ROM Base Address: 00000000
0x0038: 00000000
0x003c: Interrupt Pin: 00 Line: 00 Min Gnt: 00 Max Lat: 40
0x0000: 209a1022 02a00045 01018001 00004008
0x0010: 00000000 00000000 00000000 00000000
0x0020: 0000b401 00000000 00000000 209a1022
0x0030: 00000000 00000000 00000000 40000000
0x0040: 00000002 00000000 20000000 00000000
0x0050: c0000303 00000000 00000000 00000000
0x0060: 00000000 00000000 00000000 00000000
0x0070: 00000000 00000000 00000000 00000000
0x0080: 00000000 00000000 00000000 00000000
0x0090: 00000000 00000000 00000000 00000000
0x00a0: 00000000 00000000 00000000 00000000
0x00b0: 00000000 00000000 00000000 00000000
0x00c0: 00000000 00000000 00000000 00000000
0x00d0: 00000000 00000000 00000000 00000000
0x00e0: 00000000 00000000 00000000 00000000
0x00f0: 00000000 00000000 00000000 00000000
0:14:3: AMD CS5536 Audio
0x0000: Vendor ID: 1022, Product ID: 2093
0x0004: Command: 0045, Status: 02a0
0x0008: Class: 04 Multimedia, Subclass: 01 Audio,
Interface: 00, Revision: 01
0x000c: BIST: 00, Header Type: 00, Latency Timer: 40,
Cache Line Size: 08
0x0010: BAR io addr: 0x0000b200/0x0080
0x0014: BAR empty (00000000)
0x0018: BAR empty (00000000)
0x001c: BAR empty (00000000)
0x0020: BAR empty (00000000)
0x0024: BAR empty (00000000)
0x0028: Cardbus CIS: 00000000
0x002c: Subsystem Vendor ID: 1022 Product ID: 2093
0x0030: Expansion ROM Base Address: 00000000
0x0038: 00000000
0x003c: Interrupt Pin: 01 Line: 00 Min Gnt: 00 Max Lat: 40
0x0000: 20931022 02a00045 04010001 00004008
0x0010: 0000b201 00000000 00000000 00000000
0x0020: 00000000 00000000 00000000 20931022
0x0030: 00000000 00000000 00000000 40000100
0x0040: 00000000 00000000 00000000 00000000
0x0050: 00000000 00000000 00000000 00000000
0x0060: 00000000 00000000 00000000 00000000
0x0070: 00000000 00000000 00000000 00000000
0x0080: 00000000 00000000 00000000 00000000
0x0090: 00000000 00000000 00000000 00000000
0x00a0: 00000000 00000000 00000000 00000000
0x00b0: 00000000 00000000 00000000 00000000
0x00c0: 00000000 00000000 00000000 00000000
0x00d0: 00000000 00000000 00000000 00000000
0x00e0: 00000000 00000000 00000000 00000000
0x00f0: 00000000 00000000 00000000 00000000
0:14:4: AMD CS5536 USB
0x0000: Vendor ID: 1022, Product ID: 2094
0x0004: Command: 0046, Status: 02a0
0x0008: Class: 0c Serial Bus, Subclass: 03 USB,
Interface: 10, Revision: 02
0x000c: BIST: 00, Header Type: 00, Latency Timer: 40,
Cache Line Size: 08
0x0010: BAR mem 32bit addr: 0x04054000/0x00001000
0x0014: BAR empty (00000000)
0x0018: BAR empty (00000000)
0x001c: BAR empty (00000000)
0x0020: BAR empty (00000000)
0x0024: BAR empty (00000000)
0x0028: Cardbus CIS: 00000000
0x002c: Subsystem Vendor ID: 1022 Product ID: 2094
0x0030: Expansion ROM Base Address: 00000000
0x0038: 00000000
0x003c: Interrupt Pin: 01 Line: 00 Min Gnt: 00 Max Lat: 40
0x0000: 20941022 02a00046 0c031002 00004008
0x0010: 04054000 00000000 00000000 00000000
0x0020: 00000000 00000000 00000000 20941022
0x0030: 00000000 00000040 00000000 40000100
0x0040: 00000000 00000000 00000000 00000000
0x0050: 00000000 00000000 00000000 00000000
0x0060: 00000000 00000000 00000000 00000000
0x0070: 00000000 00000000 00000000 00000000
0x0080: 00000000 00000000 00000000 00000000
0x0090: 00000000 00000000 00000000 00000000
0x00a0: 00000000 00000000 00000000 00000000
0x00b0: 00000000 00000000 00000000 00000000
0x00c0: 00000000 00000000 00000000 00000000
0x00d0: 00000000 00000000 00000000 00000000
0x00e0: 00000000 00000000 00000000 00000000
0x00f0: 00000000 00000000 00000000 00000000
0:14:5: AMD CS5536 USB
0x0000: Vendor ID: 1022, Product ID: 2095
0x0004: Command: 0046, Status: 02a0
0x0008: Class: 0c Serial Bus, Subclass: 03 USB,
Interface: 20, Revision: 02
0x000c: BIST: 00, Header Type: 00, Latency Timer: 40,
Cache Line Size: 08
0x0010: BAR mem 32bit addr: 0x04053000/0x00001000
0x0014: BAR empty (00000000)
0x0018: BAR empty (00000000)
0x001c: BAR empty (00000000)
0x0020: BAR empty (00000000)
0x0024: BAR empty (00000000)
0x0028: Cardbus CIS: 00000000
0x002c: Subsystem Vendor ID: 1022 Product ID: 2095
0x0030: Expansion ROM Base Address: 00000000
0x0038: 00000000
0x003c: Interrupt Pin: 01 Line: 00 Min Gnt: 00 Max Lat: 40
0x0000: 20951022 02a00046 0c032002 00004008
0x0010: 04053000 00000000 00000000 00000000
0x0020: 00000000 00000000 00000000 20951022
0x0030: 00000000 00000040 00000000 40000100
0x0040: 00000000 00000000 00000000 00000000
0x0050: 00000000 00000000 00000000 00000000
0x0060: 00002020 00000000 00000000 00000000
0x0070: 00000000 00000000 00000000 00000000
0x0080: 00000000 00000000 00000000 00000000
0x0090: 00000000 00000000 00000000 00000000
0x00a0: 00000000 00000000 00000000 00000000
0x00b0: 00000000 00000000 00000000 00000000
0x00c0: 00000000 00000000 00000000 00000000
0x00d0: 00000000 00000000 00000000 00000000
0x00e0: 00000000 00000000 00000000 00000000
0x00f0: 00000000 00000000 00000000 00000000
acpidump: