EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
532 stars 163 forks source link

Linker command failed: arm64 Apple M1 #238

Closed mikerockett closed 1 year ago

mikerockett commented 2 years ago

I can't seem to be able to get this extension to build on Apple M1. Output of make is:

$ make USE_PGXS=1
gcc -Wall \
  -Wmissing-prototypes \
  -Wpointer-arith \
  -Wdeclaration-after-statement \
  -Werror=vla \
  -Wendif-labels \
  -Wmissing-format-attribute \
  -Wformat-security \
  -fno-strict-aliasing \
  -fwrapv \
  -Wno-unused-command-line-argument \
  -mmacosx-version-min=10.12 \
  -bundle \
  -multiply_defined suppress \
  -o mysql_fdw.so connection.o option.o deparse.o mysql_query.o mysql_fdw.o \
  -L/Applications/Postgres.app/Contents/Versions/12/lib \
  -L/Applications/Postgres.app/Contents/Versions/12/lib \
  -L/Applications/Postgres.app/Contents/Versions/12/lib \
  -Wl,-dead_strip_dylibs \
  -bundle_loader /Applications/Postgres.app/Contents/Versions/12/bin/postgres
ld: can't link with a main executable file '/Applications/Postgres.app/Contents/Versions/12/bin/postgres' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql_fdw.so] Error 1

Attempting to install directly with PGXN failed due to incompatible Postgres versions.

I could likely get around this by reverting to an x86 build of Postgres, but would prefer not to if there is a better way.

What's the best way to get this to work?

mikerockett commented 2 years ago

Any updates on this?

mikerockett commented 2 years ago

Apologies, I now see that I am wrong. My Postgres is indeed x86 (v12), but the extension is being built as arm64, and therefore they cannot be linked. I'm not very familiar with gcc, so not sure if I can target x86 on arm64 so they can be linked, but will try…

mikerockett commented 2 years ago

@jeevanchalke I am unable to get this working, especially with my limited clang/gcc knowledge. Would you be able to assist?

mikerockett commented 2 years ago

After an update of Postgres for Mac, it seems that make install works, but installcheck failed because of the following:

+ERROR:  incompatible library "/Applications/Postgres.app/Contents/Versions/12/lib/postgresql/mysql_fdw.so": missing magic block
+HINT:  Extension libraries are required to use the PG_MODULE_MAGIC macro.

I have no idea what this means, but I'm going to go ahead and guess that the compilation succeeded but did not use the macro (whatever it is for).

Looks like I'm going to have to attempt this in docker…