Re: Hard links created when installing gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

On Sat, Jul 13, 2024 at 04:52:48PM -0700, Jack Pugmire via Gcc-help wrote:
> Installing gcc with `make install` on x86_64 Linux creates files
> "prefix/bin/c++" and "prefix/bin/g++" that are hard linked together.
> 
> It is more convenient for me to make "prefix/bin/c++" a symbolic link to
> g++ instead.
> 
> I have two questions:
> - Could doing this break any common processes that interact with g++, e.g.
> detection by CMake or Bazel?

It could.  There are things that see if two things are the same by
looking if they are the same inode.

> - Why does `make install` create hard links (a/o/t symbolic links) in the
> first place? Maybe not all platforms have symbolic links, but x86_64 Linux
> always does as far as I know.

Hard links are faster.  Hard links are more efficient.  Hard links
existed before symbolic links did.

If you want to have GCC optionally use symbolic links here, implement
that, and send a patch?

> On many systems, there is a file "/usr/bin/cc" that is a symbolic link to
> gcc (or another C compiler), and this appears to work fine. It also seems
> bad to create hard links like that, so maybe the GCC build files could be
> updated to change this behavior. I could probably do it myself if it would
> be helpful.

You *cannot* create hardlinks across filesystems, and /usr might well
be a different filesystem.

> Or maybe there's a good reason for the hard link! Please let me know if
> this is the case.

Like I said, it is faster, and more efficient.  Also, symbolic links do
not exist on all systems, did not exist on many systems GCC was used on
long ago, so historical something?

Hardlinks do not exist on all systems either, I bet there is some
fallback somewhere already (or this is only done if the system can
handle it anyway).

GL;HF,


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux