I'm not exactly sure what the history behind this, but Debian and Ubuntu currently wraps around some of the PostgreSQL utilities with something called pg_wrapper. This utility uses LD_PRELOAD to instruct the linker to linker against libreadline. So there are two libraries here that are similar:

It seems like libedit uses ABI that libreadline does and essentially reimplements the functionality of libreadline under a different more permissive license. This seems permissible to me, but regardless let's assume it is.

That said, it is my suspicion that using LD_PRELOAD to circumvent the license on indefensible. Debian relinks the runtime that was built against libedit with libreadline.

The GPL FAQ says,

Linking a GPL covered work statically or dynamically with other modules is making a combined work based on the GPL covered work. Thus, the terms and conditions of the GNU General Public License cover the whole combination. See also What legal issues come up if I use GPL-incompatible libraries with GPL software?

It's also very clear Debian's goal is to circumvent the license in that, additionally acknowledging that libedit is "broke",

pg_wrapper: If libreadline is installed, LD_PRELOAD this for "psql", to avoid using the rather broken libedit. We need to build the postgresql-X.Y packages against libedit for license reasons (#603599), but as libreadline has a drop-in compatible ABI, this works around the licensing restrictions. Thanks to Andreas Barth for working this out! Add a recommends to libreadline6. (Closes: #608442, #607907, #607109, #611918)

Is there any precedence for this? Is a non-GPLed program that is dependent on an ABI implemented in by two distinct libraries one of which is GPLed free to utilize the GPL'ed library because it's not a derivative work of the GPL'ed library, but only an ABI that is shared in common with two libraries?

And more simply, can you use GPLed code and not yourself be a derivative work?

You can read more about LD_PRELOAD here.

  • What the authors of the GPL want, and what they can legally enforce, are two completely different things. Loading program A and library B into memory at the same time doesn't actually make program A a derivative work of library B.
    – Simon B
    Commented Jun 19, 2018 at 8:29
  • 1
    So I can write an ABI-compatible shim for any GPL'd program, give it a BSD license, and work around the GPL's restrictions? I doubt that would hold up in court. Commented Jul 19, 2018 at 15:32

2 Answers 2


Running a program (in any fashion) is not an act restricted by the GNU GPL, so this cannot be a violation of the GPL. The version of libreadline distributed by Debian is in compliance with the GPL, the version of PostgreSQL is in compliance with its license, so this is all OK.

Whether you think this is a hole in the GPL is a different question and definitely off-topic here.

  • "version of PostgreSQL is in compliance with its license" I don't believe that to be true, and you don't actually substantiate it. The Version of PostgreSQL distributed with Debian links into GPL code without itself being GPL-compatible. Where is that OK? Commented Jul 20, 2018 at 16:57

What the authors of the GPL want, and what they can legally enforce, are two different things.

Many countries have now dragged their copyright laws into the 21st century, and no longer consider loading a program into computer memory to be "copying".

So you start off with a non-GPL program and a GPL library sitting on the hard disk. These are copies, but that's fine because the GPL allows you to copy things, and the program doesn't actually contain any part of the library.

You then run the program, asking it to use the GPL library. The two get loaded into memory. The program in memory now would be a derivative of the library.

But if copyright law allows loading things into memory where you are, then it isn't legally making a copy anywhere, so the copyright law doesn't care. If this is the case, then there's nothing anyone can do to legally enforce the dynamic loading part of the GPL.

If in doubt, ask a lawyer in your juristiction. Copyright law varies between countries.

  • This is a little weak. Nobody argues that two programs that communicate with each other constitute a derived work because they're both loaded into memory at the same time, nor does FSF make that claim. Commented Jul 19, 2018 at 15:28
  • @RobertHarvey The FSF says "Linking a GPL covered work statically or dynamically with other modules is making a combined work based on the GPL covered work." So they are claiming that dynamically loading a library makes a derivative work. But in many countries that claim is unenforceable.
    – Simon B
    Commented Jul 19, 2018 at 22:53
  • 1
    That's not what you said in your answer. Commented Jul 19, 2018 at 23:14
  • I think this also raises the question that if linking isn't the violation, then why is LD_PRELOAD needed at all? Also, if this is your understanding what is the difference between the GPL and LGPL and will the court view them as the same license? Commented Jul 20, 2018 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.