Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoconf script will break if proj version jumps to double digit #2270

Open
jeroen opened this issue Nov 22, 2023 · 4 comments
Open

Autoconf script will break if proj version jumps to double digit #2270

jeroen opened this issue Nov 22, 2023 · 4 comments

Comments

@jeroen
Copy link
Contributor

jeroen commented Nov 22, 2023

Trying to make cross compiling work, I found that there are several places in your configure where you are version checking PROJ using cut -c 1 or cut -c 1,2 which assumes both major and minor have exactly 1 digit.

So if proj ever jumps to version 10, then your configure script treats this as version 1. This also applies to lwgeom.

While we are at it:

The script seems to lookup the proj_version several times using a mix of methods. When cross compiling we should be assuming the version that is given by pkgconfig:

sf/configure.ac

Lines 355 to 356 in 1ea4d8b

PROJ_VERSION=`${PROJ_CONFIG} --modversion`
PROJV1=`echo "${PROJ_VERSION}" | cut -c 1`

We cannot run test programs like this in a cross environment:

sf/configure.ac

Lines 468 to 470 in 1ea4d8b

${CC} ${CFLAGS} ${CPPFLAGS} -o proj_conf_test proj_conf_test.c ${PROJ_LIBS}
proj_version=`./proj_conf_test`

So perhaps the script can also be simplified a bit lookup the proj version only once, and only fall back on running a test program if no pkg-config --modversion version was found ?

@edzer
Copy link
Member

edzer commented Jan 10, 2024

Great thinking - thanks for the PR!

@edzer
Copy link
Member

edzer commented Jan 10, 2024

Still fails for wasm - any ideas what to do?

@jeroen
Copy link
Contributor Author

jeroen commented Jan 10, 2024

Looking at errors.txt that the configure generates, the problem seems to linking errors at this line:

https://github.com/r-spatial/lwgeom/blob/7cd821b7aaf63b6bf149a8f97981b8d98336795b/configure.ac#L148

Which are caused by a duplicated -lsqlite3:

wasm-ld: error: duplicate symbol: sqlite3_initialize
>>> defined in /opt/webr/wasm/lib/libsqlite3.a(sqlite3.o)
>>> defined in /opt/webr/wasm/lib/libsqlite3.a(sqlite3.o)

wasm-ld: error: duplicate symbol: sqlite3_malloc
>>> defined in /opt/webr/wasm/lib/libsqlite3.a(sqlite3.o)
>>> defined in /opt/webr/wasm/lib/libsqlite3.a(sqlite3.o)

...

The wasm linker is a bit more pedantic than other linkers, and doesn't allow duplicated flags. The problem is that pkg-config proj --libs already contains -lsqlite3 so in this the line linked above you shouldn't add -lsqlite3 if this is already contained in ${LIBS}.

# pkg-config --libs proj
-lproj -lstdc++ -lsqlite3 -lpthread -ltiff -lcurl -ldl

edzer added a commit to r-spatial/lwgeom that referenced this issue Jan 11, 2024
@edzer
Copy link
Member

edzer commented Jan 11, 2024

That now passes, but hangs on geos; I looked at the successful wasm build of sf, but could not find the configure step being executed there (which has the same code as the thing that now hangs lwgeom wasm build).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants