GNU bug report logs - #78975
Feature request: per-library compiler

Previous Next

Package: automake;

Reported by: William T Jones <w.t.jones <at> nasa.gov>

Date: Wed, 9 Jul 2025 01:54:02 UTC

Severity: wishlist

To reply to this bug, email your comments to 78975 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-automake <at> gnu.org:
bug#78975; Package automake. (Wed, 09 Jul 2025 01:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to William T Jones <w.t.jones <at> nasa.gov>:
New bug report received and forwarded. Copy sent to bug-automake <at> gnu.org. (Wed, 09 Jul 2025 01:54:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: William T Jones <w.t.jones <at> nasa.gov>
To: bug-automake <at> gnu.org
Subject: Feature request: per-library compiler
Date: Tue, 8 Jul 2025 21:53:11 -0400
[Message part 1 (text/plain, inline)]
I would like to request a feature for GNU Automake if it is possible.

When building programs and libraries with GNU Autotools (libtool, 
aclocal, automake, and autoconf) it is sometimes desirable to compile 
the same source with a custom compiler (other than CC, CXX, etc.).  A 
sample use case is to compile the same source file for multiple device 
accelerator architectures (CUDA, HIP, CPU, etc.) into a specific program 
or library.

In this use case, the same source modules need to be compile and linked 
into a device specific program or library.  Since the same source would 
be compiled for multiple devices, it would be advantageous to compile 
the source with multiple compilers within a single Makefile.am.  The 
desire would be to specify the compiler on a per-program (or 
per-library) basis in keeping with the ability to specify program and 
library variables (`maude_CFLAGS', `maude_LINK', etc.).  The suggestion 
would be to add new variables (`maude_CC', `maude_CXX', etc.) and use 
those in the custom object targets (`maude-%.o: %.c' where the stem is 
expanded) in place of $(CC), $(CXX), etc..

An example Makefile.am would contain the following:

lib_LTLIBRARIES = libcpu.la libcuda.la libhip.la

my_SRCS = source.c

libcpu_la_SOURCES = $(my_SRCS)
libcpu_la_CFLAGS =

libcuda_la_SOURCES = $(my_SRCS)
libcuda_la_CFLAGS = -Wc,-x,cu -Wc,-dc
libcuda_la_CC = nvcc

libhip_la_SOURCES = $(my_SRCS)
libhip_la_CFLAGS = -Wc,-fgpu-rdc -Wc,-dc
libhip_la_LDFLAGS = -Wc,-fgpu-rdc,--hip-link
libhip_la_CC = hipcc

And, as an example, the generated rule for compiling source.c for 
libcuda.la would be generated as ($CC replaced with $libcuda_la_CC):

libcuda_la-source.lo: source.c
        $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) 
$(LIBTOOLFLAGS) --mode=compile $(libcuda_la_CC) $(DEFS) 
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) 
$(libcuda_la_CFLAGS) $(CFLAGS) -MT libcuda_la-source.lo -MD -MP -MF 
$(DEPDIR)/libcuda_la-source.Tpo -c -o libcuda_la-source.lo `test -f 
'source.c' || echo '$(srcdir)/'`source.c
        $(AM_V_at)$(am__mv) $(DEPDIR)/libcuda_la-source.Tpo 
$(DEPDIR)/libcuda_la-source.Plo
#       $(AM_V_CC)source='source.c' object='libcuda_la-source.lo' 
libtool=yes \
#       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
#       $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) 
$(LIBTOOLFLAGS) --mode=compile $(libcuda_la_CC) $(DEFS) 
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) 
$(libcuda_la_CFLAGS) $(CFLAGS) -c -o libcuda_la-source.lo `test -f 
'source.c' || echo '$(srcdir)/'`source.c

Is this possible and acceptable?

If there is another way to accomplish this task, I am open to it. 
However, I have researched the topic with documentation searches and 
failed AI chats and have not discovered an elegant solution.

Thank you for all of the great work,


Bill

-- 
[Message part 2 (text/html, inline)]
[signature.png (image/png, inline)]

Information forwarded to bug-automake <at> gnu.org:
bug#78975; Package automake. (Fri, 11 Jul 2025 16:31:02 GMT) Full text and rfc822 format available.

Message #8 received at 78975 <at> debbugs.gnu.org (full text, mbox):

From: Karl Berry <karl <at> freefriends.org>
To: w.t.jones <at> nasa.gov
Cc: 78975 <at> debbugs.gnu.org
Subject: Re: bug#78975: Feature request: per-library compiler
Date: Fri, 11 Jul 2025 10:30:28 -0600
Hi Bill - thanks much for the detailed and thought-out message.

    Since the same source would 
    be compiled for multiple devices, it would be advantageous to compile 
    the source with multiple compilers within a single Makefile.am.  
    ...
    add new variables (`maude_CC', `maude_CXX', etc.) and use 

It looks reasonable to me. I don't recall this coming up before. I don't
think you missed anything in your searching, but if anyone else here has
an idea for how to accomplish this, I'm sure they'll chime in.

How easy or hard this will be to implement, I just have no idea.  I will
look as soon as I have a chance, but I can't give an ETA.  Bogdan (or
anyone else), maybe you'd be able to look at it?

Thanks again,
Karl




This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.