Bug 101491 - /usr/local/include/libgccjit++.h conflicts between different GCC installations
Summary: /usr/local/include/libgccjit++.h conflicts between different GCC installations
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: jit (show other bugs)
Version: 11.1.1
: P3 normal
Target Milestone: ---
Assignee: David Malcolm
URL: https://gcc.gnu.org/pipermail/jit/202...
Keywords: patch
Depends on:
Blocks:
 
Reported: 2021-07-17 20:29 UTC by Gerald Pfeifer
Modified: 2024-04-29 07:12 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 7.5.0
Last reconfirmed: 2021-07-18 00:00:00


Attachments
install libgccjit*.h under $(libdir)/gcc/$(target_alias)/$(gcc_version) instead of $(includedir) (360 bytes, patch)
2022-11-04 20:31 UTC, John Hein
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gerald Pfeifer 2021-07-17 20:29:14 UTC
In the FreeBSD Ports Collection (and presumably similarly other distros)
we install different versions of GCC into the same prefix with

  --program-suffix=
  --libdir=
  --with-gxx-include-dir=

which has been working very well for years.

Recently users reported that /usr/local/include/libgccjit++.h is
installed by both GCC 11 and GCC 12 at least, cf. 
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257060

Looks like this should go into a version-specific directory (such
as --with-gxx-include-dir= maybe?
Comment 1 Dimitry Andric 2021-07-17 21:22:54 UTC
It appears libgccjit.h and libgccjit++.h are installed into $(includedir), via gcc/jit/Make-lang.in:

jit.install-headers: installdirs
        $(INSTALL_DATA) $(srcdir)/jit/libgccjit.h \
          $(DESTDIR)$(includedir)/libgccjit.h
        $(INSTALL_DATA) $(srcdir)/jit/libgccjit++.h \
          $(DESTDIR)$(includedir)/libgccjit++.h

This has been the case since David committed r217374. I'm unsure why these headers seem to be installed only recently?
Comment 2 David Malcolm 2021-07-17 23:08:30 UTC
I wonder why this changed recently; as Dimitry notes, this has been done the same since the initial merger of libgccjit into trunk.

I'm using $(includedir).  What should I be using?  Thanks
Comment 3 Gerald Pfeifer 2021-07-18 14:13:27 UTC
As one data point, gccjit is a "relatively newer" thing for the FreeBSD
ports of GCC, e.g. in case of lang/gcc11-devel:

  commit bb995aaf6e25e33b028fa4b32321864b48f49055
  Author: Ashish SHUKLA <ashish@FreeBSD.org>
  Date:   Tue Feb 23 09:07:37 2021 +0000

    - Enable gccjit support
    
    Approved by:    gerald (maintainer)

Looking at the diff it appears the issue was there back then already:

  --- a/lang/gcc11-devel/pkg-plist
  +++ b/lang/gcc11-devel/pkg-plist
  @@ -18,6 +18,8 @@ bin/gcov-dump%%SUFFIX%%
   bin/gcov-tool%%SUFFIX%%
   bin/gfortran%%SUFFIX%%
   bin/lto-dump%%SUFFIX%%
  +include/libgccjit++.h
  +include/libgccjit.h

Alas it only materialized when lang/gcc12-devel was added:

  commit 982ce2ea27d8d41ed4f69c6c8f1eb56f04280531
  Author: Gerald Pfeifer <gerald@FreeBSD.org>
  Date:   Mon May 3 10:45:02 2021 +0000

    lang/gcc12-devel: New port based on the 20210426 snapshot of GCC 12.0.0
    
    This is the first snapshot from trunk with the GCC 12 designation. It
    largely is a copy of lang/gcc11-devel.


(In reply to David Malcolm from comment #2)
> I wonder why this changed recently; as Dimitry notes, this has been 
> done the same since the initial merger of libgccjit into trunk.

I believe we are not looking at a regression in one of the FreeBSD ports
nor on the gccjit side, just an issue that's been there "from day 1".

Dimitry, is this consistent with your experience?


> I'm using $(includedir).  What should I be using?  Thanks

I'm not an expert, yet dug a bit and most include files appear to be 
installed in lib/gcc11/gcc/i386-portbld-freebsd11.4/11.1.1/include
which libgomp/Makefile, libquadmath/Makefile, libssp/Makefile and
others have as

   libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include

Would something like this work for libgccjit as well, David?
Comment 4 Dimitry Andric 2021-07-18 19:46:03 UTC
(In reply to Gerald Pfeifer from comment #3)
> (In reply to David Malcolm from comment #2)
> > I wonder why this changed recently; as Dimitry notes, this has been 
> > done the same since the initial merger of libgccjit into trunk.
> 
> I believe we are not looking at a regression in one of the FreeBSD ports
> nor on the gccjit side, just an issue that's been there "from day 1".
> 
> Dimitry, is this consistent with your experience?

Yes, it's only the FreeBSD gcc 11 and 12 ports that have these headers. But indeed they have been provided by gcc's Makefiles since 2014.
Comment 5 Richard Biener 2021-07-19 06:35:34 UTC
I think a more appropriate place would be where we also install OpenMP omp.h to
(libsubinclude_HEADERS)
Comment 6 Richard Biener 2021-07-28 07:07:34 UTC
GCC 11.2 is being released, retargeting bugs to GCC 11.3
Comment 7 Gerald Pfeifer 2021-09-26 09:08:12 UTC
(In reply to David Malcolm from comment #2)
> I'm using $(includedir).  What should I be using?  Thanks

(In reply to Richard Biener from comment #5)
> I think a more appropriate place would be where we also install 
> OpenMP omp.h to (libsubinclude_HEADERS)

David, any chance to can have a look following this recommendation?

It'd be good for 11.3 to address this - thank you!
Comment 8 Richard Biener 2022-01-20 12:47:18 UTC
GCC 7 contains the same install rule so definitely not a regression from GCC 10.
Comment 9 John Hein 2022-11-04 20:31:40 UTC
Created attachment 53828 [details]
install libgccjit*.h under $(libdir)/gcc/$(target_alias)/$(gcc_version) instead of $(includedir)

I've been using the attached patch on FreeBSD for a few months to install libgccjit*.h in the location of other header files under $(libdir)/gcc/$(target_alias)/$(gcc_version)/ as suggested in comment 5.  emacs uses libgccgit.h (if configured --with-native-compilation), and the emacs port builds fine with this new location.
Comment 10 John Hein 2022-11-04 20:35:39 UTC
(In reply to John Hein from comment #9)
Oops. s/libgccgit/libgccjit/ in the previous comment.
Comment 11 John Hein 2022-11-04 21:40:21 UTC
Comment on attachment 53828 [details]
install libgccjit*.h under $(libdir)/gcc/$(target_alias)/$(gcc_version) instead of $(includedir)

minor correction on patch description
Comment 12 Lorenzo Salvadore 2022-11-16 16:06:41 UTC
I have sent by mail an alternative patch:
https://gcc.gnu.org/pipermail/jit/2022q4/001572.html

It should be functionally equivalent to John's patch, but it is written with a different style. It is the patch that is now used in the FreeBSD ports tree for the lang/gcc11 and lang/gcc12 ports.