Skip to content

Conversation

@PerfectLaugh
Copy link
Contributor

The include flag causes compilation error on OCaml 5.4.0 and gcc (GCC) 15.2.1 20251022 (Red Hat 15.2.1-3)

Log:

File "src/dune", lines 1-8, characters 0-162:
1 | (library
2 |  (name bitstring)
3 |  (public_name bitstring)
4 |  (foreign_stubs
5 |   (language c)
6 |   (names bitstring_fastpath)
7 |   (flags -I.))
8 |  (libraries str unix stdlib-shims))
/usr/bin/ld: src/bitstring_fastpath.o: relocation R_X86_64_32S against
`.data' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

@xguerin
Copy link
Owner

xguerin commented Nov 11, 2025

This PR looks fine. However, I fail to see how an include path can cause the linker to fail. I'm gonna check your setup on my end to see what's going on.

@PerfectLaugh
Copy link
Contributor Author

PerfectLaugh commented Nov 11, 2025

I build on Fedora 43 x86_64. Either adding -fPIC in flags or remove the flags stanza will work.
But I suggest remove the flags completely to comply with possible standard flags in OCaml

@xguerin
Copy link
Owner

xguerin commented Nov 11, 2025

Would adding :standard help here? (cflags :standard -I.). I'm thinking -fPIC may be added in a target-specific manner and present in the default flags.

The flags without `:standard` causes compilation error on OCaml 5.4.0
and gcc (GCC) 15.2.1 20251022 (Red Hat 15.2.1-3)

Log:
```
File "src/dune", lines 1-8, characters 0-162:
1 | (library
2 |  (name bitstring)
3 |  (public_name bitstring)
4 |  (foreign_stubs
5 |   (language c)
6 |   (names bitstring_fastpath)
7 |   (flags -I.))
8 |  (libraries str unix stdlib-shims))
/usr/bin/ld: src/bitstring_fastpath.o: relocation R_X86_64_32S against
`.data' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
```
@PerfectLaugh
Copy link
Contributor Author

Would adding :standard help here? (cflags :standard -I.). I'm thinking -fPIC may be added in a target-specific manner and present in the default flags.

Sounds great. I didn't know the :standard flag before, it should be preferred.

@xguerin xguerin changed the title Remove include flag in cflags Use :standard in dune flags stanza Nov 11, 2025
@xguerin xguerin merged commit c74a424 into xguerin:master Nov 11, 2025
2 checks passed
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.

2 participants