CYaml has been a private dependency of libYams.so and linked statically
against it since 2a93d740efde7caa4bc1e74c4e3c91361c12167b.
Therefore, CYaml should be built as PIC, but it wasn't.
Since gas 2.31 (Ubuntu 20.04), which includes implicit promotion of
non-PIC reloc (R_X86_64_PC32) to PIC reloc (R_X86_64_PLT32)^1, this
issue is not revealed. However gas older than 2.31 (Ubuntu 18.04), this
PIC-ness mismatch causes linking failure with the following output:
/usr/bin/ld.gold: error: lib/libCYaml.a(api.c.o): requires dynamic R_X86_64_PC32 reloc against 'yaml_realloc' which may overflow at runtime; recompile with -fPIC
/usr/bin/ld.gold: error: lib/libCYaml.a(scanner.c.o): requires dynamic R_X86_64_PC32 reloc against 'yaml_parser_fetch_more_tokens' which may overflow at runtime; recompile with -fPIC
This patch fixes the PIC-ness mismatch by enabling
POSITION_INDEPENDENT_CODE explicitly, and adds CI job to check cmake
build system works on Ubuntu 18.04.
CYaml has been a private dependency of libYams.so and linked statically against it since 2a93d740efde7caa4bc1e74c4e3c91361c12167b. Therefore, CYaml should be built as PIC, but it wasn't.
Since gas 2.31 (Ubuntu 20.04), which includes implicit promotion of non-PIC reloc (R_X86_64_PC32) to PIC reloc (R_X86_64_PLT32)^1, this issue is not revealed. However gas older than 2.31 (Ubuntu 18.04), this PIC-ness mismatch causes linking failure with the following output:
This patch fixes the PIC-ness mismatch by enabling
POSITION_INDEPENDENT_CODE
explicitly, and adds CI job to check cmake build system works on Ubuntu 18.04.