I am new to PostgreSQL extension development and am currently working on
the *steampipe-postgres-fdw* project.

This is a *Foreign Data Wrapper (FDW) written in Go*, and while I have
successfully built it on Darwin systems, I am facing challenges when
building on Linux, particularly with *pgxs.mk <http://pgxs.mk>* against
PostgreSQL 14.

The issue arises with a Go module that is compiled into a .a archive file
using -buildmode=c-archive, leading to a *file size of approximately 393 MB*.
During the build process using *pgxs.mk <http://pgxs.mk>*, I encounter
several errors related to relocation and DWARF debug information, such as:

/usr/bin/ld: steampipe_postgres_fdw.a(go.o): relocation
R_AARCH64_ADR_PREL_PG_HI21 against symbol `type:string' which may bind
externally can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: DWARF error: line info data is bigger (0x65f0639) than the
space remaining in the section (0xe86ef9)
...

The log is for aarch64 - but I am getting similar errors for amd64 as well


Interestingly, the *build completes successfully when the .a file is
smaller* (around 100 MB).

As someone new to this area, I am a bit unclear on the following points:

   - Best practices for compiling Go code for PostgreSQL FDWs on Linux
with *pgxs.mk
   <http://pgxs.mk>*, especially regarding *-fPIC* and managing large
   archive file sizes.
   - Understanding and resolving the relocation and DWARF errors in the
   context of PostgreSQL extension development.
   - Any known issues or special considerations for building Go-based FDWs
   for PostgreSQL 14 on Linux.

Any advice, insights, or pointers to relevant resources from the community
will be helpful.

Thank you for your time and assistance.

I am attaching a minimal piece of code to be able to reproduce - although
> the *go toolchain* is required


Best regards,
Binaek Sarkar

<<attachment: fdw.zip>>

Reply via email to