pseudo: Drop static linking to sqlite3
PATCH 1/1 pseudo: Drop static linking to sqlite3
Back in 2010[1] we made pseudo statically link against sqlite3. Since then the world has changed, pseudo now has separate processes for the database in the server and the client and they have separate linking commands.
[1] http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=ad0ac0ecd38fc77daf42485489fccc10a5e1e3e7
The static sqlite3-native is causing us problems, in particular:
tmp/work/x86_64-linux/pseudo-native/1.9.0+gitAUTOINC+060058bb29-r0/recipe-sysroot-native/usr/lib/libsqlite3.a(sqlite3.o):(.data.rel+0xb0): undefined reference to `fcntl64'
which occurs if sqlite3-native was built on a machine with glibc 2.28 or later and pseudo-native is being built on glibc before that. With dyanmical linking, libc is backwards compatible and works but with static linking it does not.
There appears to be no easy way to avoid this other than adding a copy of sqlite3 into the pseudo recipe. Given the static linking doesn't seem to be required any longer due to the separate processes, drop that to fix those issues.
--- meta/conf/distro/include/no-static-libs.inc | 4 ---- meta/recipes-devtools/pseudo/pseudo.inc | 17 ++--------------- 2 files changed, 2 insertions(+), 19 deletions(-)
meta/conf/distro/include/no-static-libs.inc +0 -4
@@ -15,10 +15,6 @@ DISABLE_STATIC_pn-nativesdk-libcap = "" DISABLE_STATIC_pn-libpcap = "" # needed by gdb DISABLE_STATIC_pn-readline = "" -# needed by pseudo -DISABLE_STATIC_pn-sqlite3 = "" -DISABLE_STATIC_pn-sqlite3-native = "" -DISABLE_STATIC_pn-nativesdk-sqlite3 = "" # openjade/sgml-common have build issues without static libs DISABLE_STATIC_pn-sgml-common-native = "" DISABLE_STATIC_pn-openjade-native = ""
meta/recipes-devtools/pseudo/pseudo.inc +2 -15
@@ -30,23 +30,10 @@ PSEUDO_EXTRA_OPTS ?= "--enable-force-async --without-passwd-fallback --enable-ep # Compile for the local machine arch... do_compile () { - SQLITE_LDADD='$(SQLITE)/$(SQLITE_LIB)/libsqlite3.a' - for sqlite_link_opt in $(pkg-config sqlite3 --libs --static) - do - case "$sqlite_link_opt" in - -lsqlite3) - ;; - -l*) - SQLITE_LDADD="${SQLITE_LDADD} ${sqlite_link_opt}" - ;; - *) - ;; - esac - done if [ "${SITEINFO_BITS}" = "64" ]; then - ${S}/configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib${SITEINFO_BITS} --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --cflags="${CFLAGS}" --bits=${SITEINFO_BITS} --with-static-sqlite="$SQLITE_LDADD" --without-rpath + ${S}/configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib${SITEINFO_BITS} --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --cflags="${CFLAGS}" --bits=${SITEINFO_BITS} --without-rpath else - ${S}/configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --cflags="${CFLAGS}" --bits=${SITEINFO_BITS} --with-static-sqlite="$SQLITE_LDADD" --without-rpath + ${S}/configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --cflags="${CFLAGS}" --bits=${SITEINFO_BITS} --without-rpath fi oe_runmake ${MAKEOPTS} }
Signature · 1 line
2.20.1
Quoted 4 lines · On Sat, 9 Nov 2019 15:35:59 +0000 Richard Purdie…
Back in 2010[1] we made pseudo statically link against sqlite3. Since then the world has changed, pseudo now has separate processes for the database in the server and the client and they have separate linking commands.
I'm not sure what that has to do with the reasons for it being static? Not that I remember exactly anymore, but I think we were hitting problems caused if pseudo was dynamically linked to sqlite, but I don't remember what they were.
I'm not entirely sure I know what you mean by "separate processes for the database in the server and the client". I don't think libpseudo.so should ever do any database things at all, and it shouldn't need to link to sqlite.
Quoted 2 lines
which occurs if sqlite3-native was built on a machine with glibc 2.28 or later and pseudo-native is being built on glibc before that.
I don't think pseudo's ever been *expected* to work when built linked against things built against different libc. It is *way* too full of unholy magics that depend on knowing which libc it's using. That said, the pseudo server also shouldn't really need to be statically-linked, the only times it ever runs under pseudo, it just immediately tries to escape and not run that way.
Quoted 4 lines
There appears to be no easy way to avoid this other than adding a copy of sqlite3 into the pseudo recipe. Given the static linking doesn't seem to be required any longer due to the separate processes, drop that to fix those issues.
I don't understand the "separate processes" thing. So far as I know, pseudo has never talked to sqlite from the client. I think Jason Wessel had experimental patches at one point to do client-local sqlite work to avoid the IPC overhead, but I don't think it ever got merged because it turns out the IPC overhead is insignificant compared to everything else.
-s
Quoted 8 lines · Seebs
Quoted 4 lines · On Sat, 9 Nov 2019 15:35:59 +0000 Richard Purdie…
Back in 2010[1] we made pseudo statically link against sqlite3. Since then the world has changed, pseudo now has separate processes for the database in the server and the client and they have separate linking commands.
Quoted 4 lines
I'm not sure what that has to do with the reasons for it being static? Not that I remember exactly anymore, but I think we were hitting problems caused if pseudo was dynamically linked to sqlite, but I don't remember what they were.
I did talk briefly to Mark (also cc'd) as he wrote the original patch and he thought it was possibly because the client was also linking against sqlite3 and due to the other things the client does, that was problematic.
Quoted 4 lines
I'm not entirely sure I know what you mean by "separate processes for the database in the server and the client". I don't think libpseudo.so should ever do any database things at all, and it shouldn't need to link to sqlite.
I was under the impression the client may once have linked against it. I admit I didn't dive into history, just checked that it clearly doesn't now.
Quoted 10 lines
Quoted 3 lines
which occurs if sqlite3-native was built on a machine with glibc 2.28 or later and pseudo-native is being built on glibc before that.
I don't think pseudo's ever been *expected* to work when built linked against things built against different libc. It is *way* too full of unholy magics that depend on knowing which libc it's using. That said, the pseudo server also shouldn't really need to be statically- linked, the only times it ever runs under pseudo, it just immediately tries to escape and not run that way.
The client lib doesn't and the server side should behave just like any other linux binary afaik so we should be ok with a dynamicly linked sqlite3?
Quoted 6 lines
Quoted 5 lines
There appears to be no easy way to avoid this other than adding a copy of sqlite3 into the pseudo recipe. Given the static linking doesn't seem to be required any longer due to the separate processes,
drop that to fix those issues.
Quoted 6 lines
I don't understand the "separate processes" thing. So far as I know, pseudo has never talked to sqlite from the client. I think Jason Wessel had experimental patches at one point to do client-local sqlite work to avoid the IPC overhead, but I don't think it ever got merged because it turns out the IPC overhead is insignificant compared to everything else.
If I'm working off incorrect assumptions, is there another reason we need a static sqlite? I have tested this patch before I posted it and it seems fine in our test builds...
Cheers,
Richard
Quoted 4 lines · On Sat, 09 Nov 2019 16:30:41 +0000 Richard Purdie…
I did talk briefly to Mark (also cc'd) as he wrote the original patch and he thought it was possibly because the client was also linking against sqlite3 and due to the other things the client does, that was problematic.
It *shouldn't* link against sqlite3. But! The commit in question refers to RHEL5 and LD_LIBRARY_PATH, and I think that shook loose a memory:
I think at one point, we had a Crucial Bug Fix in sqlite3, in our build system, and if we didn't statically link, there was a risk of getting the broken version at runtime.
Quoted 3 lines
The client lib doesn't and the server side should behave just like any other linux binary afaik so we should be ok with a dynamicly linked sqlite3?
Yes.
The issue here was, I believe, not "dynamically-linked sqlite3 per se", but "dynamic linking, plus LD_LIBRARY_PATH, picking an sqlite3 which caused us specific problems".
In the Yocto environment, I think we're reasonably sure that we always get a clean Yocto-built sqlite3, and that *should* be fine.
So I'd say go for it, but if you see weird sqlite3 stuff that happens only very occasionally, look at this first. :P
-s
Quoted 26 lines · Seebs
Quoted 4 lines · On Sat, 09 Nov 2019 16:30:41 +0000 Richard Purdie…
I did talk briefly to Mark (also cc'd) as he wrote the original patch and he thought it was possibly because the client was also linking against sqlite3 and due to the other things the client does, that was problematic.
It *shouldn't* link against sqlite3. But! The commit in question refers to RHEL5 and
LD_LIBRARY_PATH, and I think that shook loose a memory:I think at one point, we had a Crucial Bug Fix in sqlite3, in our build system, and if we didn't statically link, there was a risk of getting the broken version at runtime.
Quoted 3 lines
The client lib doesn't and the server side should behave just like any other linux binary afaik so we should be ok with a dynamicly linked sqlite3?
Yes.
The issue here was, I believe, not "dynamically-linked sqlite3 per se", but "dynamic linking, plus
LD_LIBRARY_PATH, picking an sqlite3 which caused us specific problems".
Quoted 5 lines
In the Yocto environment, I think we're reasonably sure that we always get a clean Yocto-built sqlite3, and that *should* be fine.
So I'd say go for it, but if you see weird sqlite3 stuff that happens only very occasionally, look at this first. :P
With this merged, we can also drop the hack to force the sqlite static lib to be PIC:
https://git.openembedded.org/openembedded-core/commit/?id=6a58e12d19c539deac9e90679a68438497a42fa4
Quoted 45 lines · Andre McCurdy
Quoted 36 lines · Seebs
Quoted 7 lines · On Sat, 09 Nov 2019 16:30:41 +0000 Richard Purdie…
I did talk briefly to Mark (also cc'd) as he wrote the original patch
and he thought it was possibly because the client was also linking
against sqlite3 and due to the other things the client does, that was
problematic.It *shouldn't* link against sqlite3. But! The commit in question refers
to RHEL5 andLD_LIBRARY_PATH, and I think that shook loose a memory:I think at one point, we had a Crucial Bug Fix in sqlite3, in our build
system, and if we didn't statically link, there was a risk of getting
the broken version at runtime.Quoted 5 lines
The client lib doesn't and the server side should behave just like any
other linux binary afaik so we should be ok with a dynamicly linked
sqlite3?Yes.
The issue here was, I believe, not "dynamically-linked sqlite3 per se",
but "dynamic linking, plusLD_LIBRARY_PATH, picking an sqlite3 which
caused us specific problems".Quoted 7 lines
In the Yocto environment, I think we're reasonably sure that we always
get a clean Yocto-built sqlite3, and that *should* be fine.So I'd say go for it, but if you see weird sqlite3 stuff that happens
only very occasionally, look at this first. :P
Quoted 6 lines
With this merged, we can also drop the hack to force the sqlite static
lib to be PIC:https://git.openembedded.org/openembedded-core/commit/?id=6a58e12d19c539deac9e90679a68438497a42fa4
That would be good but a caution is that if pseudo is just one usecase here which brought this issue forward, since we use PIE by default this would come up elsewhere too
Quoted 7 lines · Khem Raj
Quoted 6 lines · Andre McCurdy
With this merged, we can also drop the hack to force the sqlite static
lib to be PIC:
Quoted 5 lines
Quoted 1 line
https://git.openembedded.org/openembedded-core/commit/?id=6a58e12d19c539deac9e90679a68438497a42fa4
That would be good but a caution is that if pseudo is just one usecase here which brought this issue forward, since we use PIE by default this would come up elsewhere too
The only usecase for building a static library as PIC I am aware of is when you want to link the static library into a shared library.
Usually linking a static library into a shared library is a bug and the link error is preferable since you actually intended to link with the shared library (the linker automatically uses a static library when it can't find a shared library).
There are rare exceptions when this is done intentionally. Linking a static libsqlite3.a into libpseudo.so was such an exception.
Whether the non-PIC code is PIE or not does not make a difference.
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 23 lines · Adrian Bunk
Quoted 8 lines · Khem Raj
Quoted 7 lines · Andre McCurdy
With this merged, we can also drop the hack to force the sqlite static
lib to be PIC:https://git.openembedded.org/openembedded-core/commit/?id=6a58e12d19c539deac9e90679a68438497a42fa4
Quoted 4 lines
That would be good but a caution is that if pseudo is just one usecase here which brought this issue forward, since we use PIE by default this would come up elsewhere too
The only usecase for building a static library as PIC I am aware of is when you want to link the static library into a shared library.
Usually linking a static library into a shared library is a bug and the link error is preferable since you actually intended to link with the shared library (the linker automatically uses a static library when it can't find a shared library).
Quoted 4 lines
There are rare exceptions when this is done intentionally. Linking a static libsqlite3.a into libpseudo.so was such an exception.
Whether the non-PIC code is PIE or not does not make a difference.
It’s not directly related to that more to the fact that we disable static libs by default and since this was available some other package might have depended on it inadvertently
Quoted 13 lines
cu
Adrian--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
Quoted 14 lines · Richard Purdie
Quoted 8 lines · Seebs
Quoted 4 lines · On Sat, 9 Nov 2019 15:35:59 +0000 Richard Purdie…
Back in 2010[1] we made pseudo statically link against sqlite3. Since then the world has changed, pseudo now has separate processes for the database in the server and the client and they have separate linking commands.
Quoted 4 lines
I'm not sure what that has to do with the reasons for it being static? Not that I remember exactly anymore, but I think we were hitting problems caused if pseudo was dynamically linked to sqlite, but I don't remember what they were.
Quoted 4 lines
I did talk briefly to Mark (also cc'd) as he wrote the original patch and he thought it was possibly because the client was also linking against sqlite3 and due to the other things the client does, that was problematic.
First (early) version of pseudo would fork for the server, there wasn't a seperate executed server and we had all sorts of problems with dynamic libraries being loaded and loaded from the correct paths (due to the LD_PRELOAD).
Moving to two process spaces, LD_PRELOAD and the pseudo executable happened pretty early in development, but I suspect some of this is left over from that.
Quoted 8 lines
Quoted 4 lines
I'm not entirely sure I know what you mean by "separate processes for the database in the server and the client". I don't think libpseudo.so should ever do any database things at all, and it shouldn't need to link to sqlite.
I was under the impression the client may once have linked against it. I admit I didn't dive into history, just checked that it clearly doesn't now.
The client had both from above, but also for some early logging that happened before the pseudo server was executed. Both vestiges are long fone.
Quoted 36 lines
Quoted 10 lines
Quoted 3 lines
which occurs if sqlite3-native was built on a machine with glibc 2.28 or later and pseudo-native is being built on glibc before that.
I don't think pseudo's ever been *expected* to work when built linked against things built against different libc. It is *way* too full of unholy magics that depend on knowing which libc it's using. That said, the pseudo server also shouldn't really need to be statically- linked, the only times it ever runs under pseudo, it just immediately tries to escape and not run that way.
The client lib doesn't and the server side should behave just like any other linux binary afaik so we should be ok with a dynamicly linked sqlite3?
Quoted 6 lines
Quoted 5 lines
There appears to be no easy way to avoid this other than adding a copy of sqlite3 into the pseudo recipe. Given the static linking doesn't seem to be required any longer due to the separate processes,
drop that to fix those issues.Quoted 6 lines
I don't understand the "separate processes" thing. So far as I know, pseudo has never talked to sqlite from the client. I think Jason Wessel had experimental patches at one point to do client-local sqlite work to avoid the IPC overhead, but I don't think it ever got merged because it turns out the IPC overhead is insignificant compared to everything else.
If I'm working off incorrect assumptions, is there another reason we need a static sqlite? I have tested this patch before I posted it and it seems fine in our test builds...
Cheers,
Richard
Quoted 8 lines · On Mon, 11 Nov 2019 08:17:30 -0600 Mark Hatle <[email protected]>…
First (early) version of pseudo would fork for the server, there wasn't a seperate executed server and we had all sorts of problems with dynamic libraries being loaded and loaded from the correct paths (due to the
LD_PRELOAD).Moving to two process spaces,
LD_PRELOADand the pseudo executable happened pretty early in development, but I suspect some of this is left over from that.
To be picky:
pseudo *still does this*. If it can't find the server, it clears the environment and respawns it. There were problems with this for the longest time, which turned out to be because I was calling setenv to clean the environment, and bash *overrides setenv*, so if the program spawning the pseudo server was bash, things went wrong. It should actually be fixed now and work pretty well.
-s