Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Cause the situation on Linux is absurd!

Your complaints are reasonable, but gcc already does this. Here, I'll show you how:

> You pass some flags -L and -l to the compiler/linker, the linker links something and nobody knows what.

I agree, it would be really nice to be able to specific exact shared object paths instead of using -L and -l. Build systems typically already know the full paths to all the objects and the abstraction here is often unhelpful.

This could be remedied fairly easily by allowing (for example) -l to take an absolute path to an object rather than searching -L paths. But gcc already does this - you can just put the shared object on the command line directly like so:

Change this: gcc -lfoo bar.c

Into this: gcc bar.c /path/to/foo.so

The effect is the same, but more explicit. The foo.so.x object will be linked and added to the SONAME list.

> Nobody guarantees that what the linker links is what the runtime linker uses.

This part, however, is by design. We explicitly do NOT want what the linker links to be what the runtime uses. This is how we update shared objects between minor versions to fix bugs without reinstalling every binary on the entire system!

Letting libfoo.so.1 link to libfoo.so.1.x is a huge feature. Locking in an explicit minor version would defeat the entire purpose of dynamic linking.



> Letting libfoo.so.1 link to libfoo.so.1.x is a huge feature. Locking in an explicit minor version would defeat the entire purpose of dynamic linking.

My suggestion is to continue copying the SONAME into DT_NEEDED, and record the dir the lib was found in as an rpath.

I did not say it should fix the lib by filename.


Well, you complained about ambiguity in the search process during build, and referencing by path is how to fix that.

Regarding runtime, we absolutely do not want to implicitly embed build paths. As others have said because it's unlikely we will put them in the same place, and it's unlikely we will build and run on the same systems.

The runtime library management system is going to have a structure for where to place libraries. It may be as simple as tossing them in /usr/lib, or it may be somthing where we have different paths for each application. We can't do this if the compiler implicitly dictates universal linker paths.

One aspect I think you may also be missing is that shared objects themselves have DT_NEEDED and rpaths. You would quickly run into very confusing conflicts between binaries built on different systems, or with different build environments.

It's hard to see a problem here, since adding an rpath is very easy. You appear to be asking for implicit, hidden behavior in the compiler which doesn't fit the vast majority of use cases.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: