pgcopydb icon indicating copy to clipboard operation
pgcopydb copied to clipboard

compile error relocation R_X86_64_32S against symbol '__libc_csu_fini' can not be used when making a shared object

Open plvnv opened this issue 10 months ago • 2 comments

I get the following error when compiling from source (0.15.57.g7ae034e )

sudo make USE_PGXS=1 PG_CONFIG=/opt/pgpro/std-13/bin/pg_config install

...
...
...
gcc -std=gnu99 -std=c99 -D_GNU_SOURCE -g -I /opt/pgpro/std-13/include -I /opt/pgpro/std-13/include/server -I /opt/pgpro/std-13/include/internal -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -I/usr/include/et -Wformat -Wall -Werror=implicit-int -Werror=implicit-function-declaration -Werror=return-type -Wno-declaration-after-statement -D_WANT_SEMUN -Wno-missing-braces -I/home/postgres/pgcopydb/src/bin/pgcopydb/../lib/pg -I/home/postgres/pgcopydb/src/bin/pgcopydb/../lib/log/src/ -I/home/postgres/pgcopydb/src/bin/pgcopydb/../lib/subcommands.c/ -I/home/postgres/pgcopydb/src/bin/pgcopydb/../lib/libs/ -I/home/postgres/pgcopydb/src/bin/pgcopydb/../lib/parson/ -I/home/postgres/pgcopydb/src/bin/pgcopydb/../lib/uthash/ -I/home/postgres/pgcopydb/src/bin/pgcopydb/../lib/jenkins/ -I/home/postgres/pgcopydb/src/bin/pgcopydb/../lib/sqlite/ -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2 -fpie -Wl,-pie -Wformat -Wformat-security -Werror=format-security -z noexecstack -Wl,-z,relro -Wl,-z,now  cli_clone_follow.o pgsql.o env_utils.o cli_sentinel.o cli_compare.o file_utils.o extensions.o progress.o cli_snapshot.o filtering.o string_utils.o ld_stream.o ld_test_decoding.o parsing_utils.o copydb.o cli_copy.o ini_implementation.o cli_ping.o lock_utils.o ld_transform.o ld_replay.o follow.o catalog.o compare.o pidfile.o cli_stream.o sentinel.o dump_restore.o copydb_schema.o cli_common.o sequences.o cli_dump.o main.o blobs.o pg_utils.o summary.o signals.o cli_restore.o snapshot.o queue_utils.o indexes.o table-data.o cli_list.o schema.o cli_root.o ld_apply.o vacuum.o pgcmd.o ld_wal2json.o lib-log.o lib-commandline.o lib-parson.o lib-snprintf.o lib-strerror.o lib-dumputils.o lib-string_utils.o lib-lookup3.o lib-sqlite3.o  -L /opt/pgpro/std-13/lib -L /opt/pgpro/std-13/lib -L/usr/lib64/llvm9.0/lib -L/usr/lib64 -Wl,--as-needed -Wl,-rpath,'/opt/pgpro/std-13/lib',--enable-new-dtags -lpgcommon -lpgport -lpthread -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lrt -ldl -lm  -lpq -lncurses -lgc -o pgcopydb
/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o: relocation R_X86_64_32S against symbol `__libc_csu_fini' can not be used when making a shared object; recompile with -fPIC
/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object
/bin/ld: lib-sqlite3.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/bin/ld: /opt/pgpro/std-13/lib/libpgcommon.a(rmtree.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/bin/ld: /opt/pgpro/std-13/lib/libpgcommon.a(fe_memutils.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/bin/ld: /opt/pgpro/std-13/lib/libpgcommon.a(logging.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/bin/ld: /opt/pgpro/std-13/lib/libpgcommon.a(pgfnames.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/bin/ld: /opt/pgpro/std-13/lib/libpgport.a(path.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [pgcopydb] Error 1
make[2]: Leaving directory `/home/postgres/pgcopydb/src/bin/pgcopydb'
make[1]: *** [pgcopydb] Error 2
make[1]: Leaving directory `/home/postgres/pgcopydb/src/bin'
make: *** [bin] Error 2

previous version (https://github.com/dimitri/pgcopydb/releases/tag/v0.14.1) compile without erorrs

OS Red Hat Enterprise Linux Server release 7.8 (Maipo)

plvnv avatar Apr 19 '24 12:04 plvnv

Can you try editing the Makefile to add -fPIC as instructed and see if that fixes your build?

https://github.com/dimitri/pgcopydb/blob/fc67d3465e85166ccccefc2fcefc0af7d518f815/src/bin/pgcopydb/Makefile#L81

dimitri avatar Apr 19 '24 12:04 dimitri

With

SECURITY_CFLAGS += -fpic

Looks like it worked, thx

 15:47:05.813 31122 INFO   Running pgcopydb version 0.15.57.g7ae034e.dirty from "/opt/pgpro/std-13/bin/pgcopydb"
pgcopydb version 0.15.57.g7ae034e.dirty
compiled with PostgreSQL 13.14 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
compatible with Postgres 11, 12, 13, 14, 15, and 16

plvnv avatar Apr 19 '24 12:04 plvnv

Closing for triage. If there is something we should do in the project itself please add more information and re-open this issue.

dimitri avatar May 30 '24 10:05 dimitri