Ading stdlib as a dependency in fpm caused demo build to fail

All I did was add stdlib as a dependency in fpm.toml and the example demo file failed to build and run. In fact, nothing builds successfully.

Compilation reached 97% before failure:

libstdlib.so                           failed.
[ 97%] Compiling...
/usr/bin/x86_64-linux-gnu-ld.bfd: warning: build/gfortran_8E7A42A570C9EF51/foo/build_dependencies_stdlib_src_stdlib_linalg_iterative_solvers_bicgstab.f90.o: requires executable stack (because the .note.GNU-stack section is executable)
/usr/bin/x86_64-linux-gnu-ld.bfd: build/gfortran_8E7A42A570C9EF51/foo/build_dependencies_stdlib_src_stdlib_bitsets_large.f90.o: warning: relocation against `__stdlib_bitsets_MOD___vtab_stdlib_bitsets_Bitset_large' in read-only section `.text'
/usr/bin/x86_64-linux-gnu-ld.bfd: build/gfortran_8E7A42A570C9EF51/foo/build_dependencies_stdlib_src_stdlib_linalg_iterative_solvers_bicgstab.f90.o: relocation R_X86_64_PC32 against symbol `__stdlib_linalg_iterative_solvers_MOD___vtab_4A5BD6B' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld.bfd: final link failed: bad value
collect2: error: ld returned 1 exit status
<ERROR> Compilation failed for object " libstdlib.so "

I am on Ubuntu 26.04.
My gcc/gfortran version is version 16.0.1 20260322 .

I tried adding fPIC via --flag with the same result.

The actual error is final link failed: bad value, which is not very informative. :slight_smile:

Due to the other warning, one possibility is a bug related to executable stack, GFortran, Linux and stdlib. But I don’t know if that’s the cause.

If you want to get it fixed, create a minimal reproducible example of this bug — minimize the stdlib and all the things you compile, while still getting this exact bug. Then it will be easy to determine what is causing it. You can ask an AI agent to do this for you, they are very good at this kind of thing.