Makefile: Set CC/AR variable only if it doesn't have a value
PATCH 1/1 Makefile: Set CC/AR variable only if it doesn't have a value
This helps it compile with clang or any other compilers besides gcc
--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -1,6 +1,6 @@ VERSION = 0.96 -CC=$(CROSS_COMPILE)gcc -AR=$(CROSS_COMPILE)ar +CC?=$(CROSS_COMPILE)gcc +AR?=$(CROSS_COMPILE)ar OBJDIR = bld
Signature · 1 line
2.6.4
I believe the patch does not have the desired effect, because make(1) always sets CC automatically:
$ cat raj.mk CROSS_COMPILE=x86_64-linux-gnu- CC?=$(CROSS_COMPILE)gcc .PHONY: default default: @echo CC=$(CC) $ make -f raj.mk CC=cc
With your patch, those who specify CROSS_COMPILE, or for whom gcc and cc are different, will get different (worse) behavior.
I believe this idea has been discussed before, but it is hard to search for because few search engines will let you search on "CC ?=" and not just ignore the "?=".
Also I am not sure why you are submitting this patch on -rt-users, it doesn't seem to be particularly relevant to the RT patchset.
Jeff
Quoted 5 lines · On Mon, 4 Jan 2016 07:39:04 -0600 Jeff Epler <[email protected]> wrote:
Also I am not sure why you are submitting this patch on -rt-users, it doesn't seem to be particularly relevant to the RT patchset.
Jeff
linux-rt-users also is for discussion of RT related user-space code, such as the rt-tests collection.
Clark
Quoted 15 lines · Jeff Epler
I believe the patch does not have the desired effect, because make(1) always sets CC automatically:
$ cat raj.mk CROSS_COMPILE=x86_64-linux-gnu- CC?=$(CROSS_COMPILE)gcc .PHONY: default default: @echo CC=$(CC) $ make -f raj.mk CC=cc
Quoted 2 lines
With your patch, those who specify
CROSS_COMPILE, or for whom gcc and cc are different, will get different (worse) behavior.
Right. I think if CC was used as such with out constructing out of CROSS_COMPILE in Makefile then my issue would be fixed too. However this would mean that cross compiling users now have to pass CC = <cross-compiler> themselves instead of CROSS_COMPILE prefix. Is that acceptable ?
Quoted 7 lines
I believe this idea has been discussed before, but it is hard to search for because few search engines will let you search on "CC ?=" and not just ignore the "?=".
Also I am not sure why you are submitting this patch on -rt-users, it doesn't seem to be particularly relevant to the RT patchset.
See the MAINTAINERS file, I just followed whats in there.
Quoted 2 lines
Jeff
Quoted 15 lines · Khem Raj
Quoted 15 lines · Jeff Epler
I believe the patch does not have the desired effect, because make(1) always sets CC automatically:
$ cat raj.mk CROSS_COMPILE=x86_64-linux-gnu- CC?=$(CROSS_COMPILE)gcc .PHONY: default default: @echo CC=$(CC) $ make -f raj.mk CC=cc
Quoted 7 lines
Quoted 2 lines
With your patch, those who specify
CROSS_COMPILE, or for whom gcc and cc are different, will get different (worse) behavior.Right. I think if CC was used as such with out constructing out of
CROSS_COMPILEinMakefilethen my issue would be fixed too. However this would mean that cross compiling users now have to pass CC = <cross-compiler> themselves instead ofCROSS_COMPILEprefix. Is that acceptable ?
You could play with something like:
ifeq($(origin CC),default)
CC=$(CROSS_COMPILE)gcc
endif
but not sure I'd like the result. If you asked me, I'd drop all that CROSS_COMPILE stuff.
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · Khem Raj
Quoted 14 lines · Jeff Epler
Quoted 13 lines
I believe the patch does not have the desired effect, because make(1) always sets CC automatically:
$ cat raj.mk CROSS_COMPILE=x86_64-linux-gnu- CC?=$(CROSS_COMPILE)gcc .PHONY: default default: @echo CC=$(CC) $ make -f raj.mk CC=cc
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
With your patch, those who specify
CROSS_COMPILE, or for whom gcc and cc are different, will get different (worse) behavior.Right. I think if CC was used as such with out constructing out of
CROSS_COMPILEinMakefilethen my issue would be fixed too. However this would mean that cross compiling users now have to pass CC = <cross-compiler> themselves instead ofCROSS_COMPILEprefix. Is that acceptable ?
But what is really your issue? Even after this patch, you'll have to run
make CC=<path-to-clang> AR=<path-to-clang-ar>
and this will already override it in the current situation.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout dot vandecappelle at essensium dot com Senior Embedded Software Architect . . . . . . +32-478-010353 (mobile) Essensium, Mind division . . . . . . . . . . . . . . http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium . . . . . BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Quoted 22 lines · Arnout Vandecappelle
Quoted 14 lines · Khem Raj
Quoted 14 lines · Jeff Epler
Quoted 13 lines
I believe the patch does not have the desired effect, because make(1) always sets CC automatically:
$ cat raj.mk CROSS_COMPILE=x86_64-linux-gnu- CC?=$(CROSS_COMPILE)gcc .PHONY: default default: @echo CC=$(CC) $ make -f raj.mk CC=ccQuoted 6 lines
Quoted 2 lines
Quoted 2 lines
With your patch, those who specify
CROSS_COMPILE, or for whom gcc and cc are different, will get different (worse) behavior.Right. I think if CC was used as such with out constructing out of
CROSS_COMPILEinMakefilethen my issue would be fixed too. However this would mean that cross compiling users now have to pass CC = <cross-compiler> themselves instead ofCROSS_COMPILEprefix. Is that acceptable ?
Quoted 5 lines
But what is really your issue? Even after this patch, you'll have to run
make CC=<path-to-clang> AR=<path-to-clang-ar>
and this will already override it in the current situation.
currently it ignores CC from environment. So there is no way to specify a compiler which is not called {something}gcc
Quoted 1 line
Quoted 3 lines · Clark Williams
linux-rt-users also is for discussion of RT related user-space code, such as the rt-tests collection.
Clark
I apologize. I didn't read the original patch closely enough and incorrectly believed it was a proposed patch for the top-level Makefile in the linux kernel source tree.
Jeff
Quoted 24 lines · Uwe Kleine-König
Quoted 15 lines · Khem Raj
Quoted 15 lines · Jeff Epler
I believe the patch does not have the desired effect, because make(1) always sets CC automatically:
$ cat raj.mk CROSS_COMPILE=x86_64-linux-gnu- CC?=$(CROSS_COMPILE)gcc .PHONY: default default: @echo CC=$(CC) $ make -f raj.mk CC=ccQuoted 7 lines
Quoted 2 lines
With your patch, those who specify
CROSS_COMPILE, or for whom gcc and cc are different, will get different (worse) behavior.Right. I think if CC was used as such with out constructing out of
CROSS_COMPILEinMakefilethen my issue would be fixed too. However this would mean that cross compiling users now have to pass CC = <cross-compiler> themselves instead ofCROSS_COMPILEprefix. Is that acceptable ?
Quoted 8 lines
You could play with something like:
ifeq($(origin CC),default)
CC=$(CROSS_COMPILE)gcc
endifbut not sure I'd like the result. If you asked me, I'd drop all that
CROSS_COMPILEstuff.
Why? Isn't this the normal way of triggering cross-compile? AFIAK, that's how the kernel does it, and that seems like a pretty sane way.
And yes, I compile rt-tests to several architectures, so I'm quite fond of the CROSS_COMPILE switch. In fact, I might get cross if you cross it out :)
Signature · 1 line
Henrik Austad
Quoted 34 lines · Henrik Austad
Quoted 30 lines · Uwe Kleine-König
Quoted 15 lines · Khem Raj
Quoted 15 lines · Jeff Epler
I believe the patch does not have the desired effect, because make(1) always sets CC automatically:
$ cat raj.mk CROSS_COMPILE=x86_64-linux-gnu- CC?=$(CROSS_COMPILE)gcc .PHONY: default default: @echo CC=$(CC) $ make -f raj.mk CC=ccQuoted 7 lines
Quoted 2 lines
With your patch, those who specify
CROSS_COMPILE, or for whom gcc and cc are different, will get different (worse) behavior.Right. I think if CC was used as such with out constructing out of
CROSS_COMPILEinMakefilethen my issue would be fixed too. However this would mean that cross compiling users now have to pass CC = <cross-compiler> themselves instead ofCROSS_COMPILEprefix. Is that acceptable ?You could play with something like:
ifeq($(origin CC),default)
CC=$(CROSS_COMPILE)gcc
endif
Quoted 5 lines
Quoted 2 lines
but not sure I'd like the result. If you asked me, I'd drop all that
CROSS_COMPILEstuff.Why? Isn't this the normal way of triggering cross-compile? AFIAK, that's how the kernel does it, and that seems like a pretty sane way.
except, kernel lets you override CC if you want to.
Quoted 3 lines
And yes, I compile rt-tests to several architectures, so I'm quite fond of the
CROSS_COMPILEswitch. In fact, I might get cross if you cross it out :)
All you would need is to add
CC = ${CROSS_COMPILE}gcc in one place in your Make env
Quoted 3 lines
--
Henrik Austad
Hello Henrik,
Quoted 31 lines · Henrik Austad
Quoted 30 lines · Uwe Kleine-König
Quoted 15 lines · Khem Raj
Quoted 15 lines · Jeff Epler
I believe the patch does not have the desired effect, because make(1) always sets CC automatically:
$ cat raj.mk CROSS_COMPILE=x86_64-linux-gnu- CC?=$(CROSS_COMPILE)gcc .PHONY: default default: @echo CC=$(CC) $ make -f raj.mk CC=ccQuoted 7 lines
Quoted 2 lines
With your patch, those who specify
CROSS_COMPILE, or for whom gcc and cc are different, will get different (worse) behavior.Right. I think if CC was used as such with out constructing out of
CROSS_COMPILEinMakefilethen my issue would be fixed too. However this would mean that cross compiling users now have to pass CC = <cross-compiler> themselves instead ofCROSS_COMPILEprefix. Is that acceptable ?You could play with something like:
ifeq($(origin CC),default)
CC=$(CROSS_COMPILE)gcc
endif
Quoted 5 lines
Quoted 2 lines
but not sure I'd like the result. If you asked me, I'd drop all that
CROSS_COMPILEstuff.Why? Isn't this the normal way of triggering cross-compile? AFIAK, that's how the kernel does it, and that seems like a pretty sane way.
No, the normal thing to trigger a cross-compile is
./configure --build=amd64 --host=mips-elf
:-)
For plain make project with no special support for cross compiling (which is the norm today), the right incarnation is:
make CC=arm-v5te-linux-gnueabi-gcc
and IMHO that's good enough. (Sometimes you also have to pass CXX, in rare cases even more.)
Quoted 2 lines
And yes, I compile rt-tests to several architectures, so I'm quite fond of the
CROSS_COMPILEswitch. In fact, I might get cross if you cross it out :)
I don't care much, because if I cross compile rt-tests someone else already found out for me how to do it, I only have to enable it in my config :-)
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · Khem Raj
This helps it compile with clang or any other compilers besides gcc
Signed-off-by Khem Raj <[email protected]>--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Makefile +0
-0
Makefile line 6
Quoted 8 lines
Makefile +2
-2@@ -1,6 +1,6 @@ VERSION = 0.96 -CC=$(CROSS_COMPILE)gcc -AR=$(CROSS_COMPILE)ar +CC?=$(CROSS_COMPILE)gcc +AR?=$(CROSS_COMPILE)ar OBJDIR = bld
I added this to the next build.
Note, I read everything in the thread, and I think there was a bit of confusion over thinking this was a kernel Makefile and not the rt-tests one. As clark said, this is indeed the appropriate place to discuss user space tools that are to do with real-time. Perhaps after [PATCH] add rt-tests: to make it clear.
This patch is fine, it changes nothing other than letting the Khem and others specify CC and AR from the command line when typing make.
Thanks