diff mbox series

make: Define default rule for .c when V=1 or V=2

Message ID 20200311023722.97494-1-aik@ozlabs.ru
State Accepted
Headers show
Series make: Define default rule for .c when V=1 or V=2 | expand

Commit Message

Alexey Kardashevskiy March 11, 2020, 2:37 a.m. UTC
The default .o:.c rule passes a short file name to gcc to when doing
"make -C <dir>", we do this a lot for all the libraries.
The file names printed in gcc errors are relative to <dir> and this
prevents vim from navigating through errors.

This passes the full file name to gcc to make it print errors with
absolute path so vim can navigate through errors nicely.

This makes it optional when V=1 or V=2 is passed.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

Or there is a better way of doing this?

I find it very annoying to work with ./lib/xxxx as we chdir a lot
and gcc does not have a flag to print full file names.


---
 make.rules | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Alexey Kardashevskiy March 30, 2020, 11:28 p.m. UTC | #1
On 11/03/2020 13:37, Alexey Kardashevskiy wrote:
> The default .o:.c rule passes a short file name to gcc to when doing
> "make -C <dir>", we do this a lot for all the libraries.
> The file names printed in gcc errors are relative to <dir> and this
> prevents vim from navigating through errors.
> 
> This passes the full file name to gcc to make it print errors with
> absolute path so vim can navigate through errors nicely.
> 
> This makes it optional when V=1 or V=2 is passed.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> 
> Or there is a better way of doing this?
> 
> I find it very annoying to work with ./lib/xxxx as we chdir a lot
> and gcc does not have a flag to print full file names.
> 

Ok, I'll push it out when qemu 5.1 starts.


> 
> ---
>  make.rules | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/make.rules b/make.rules
> index acbc8ab8ff5c..3dfbb5b136c2 100644
> --- a/make.rules
> +++ b/make.rules
> @@ -49,6 +49,10 @@ ifeq ($(V),0)
>  Q		:= @
>  MAKEFLAGS	+= --silent
>  MAKE		+= -s
> +else
> +CURDIR=$(shell pwd)
> +%.o: %.c
> +	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $(CURDIR)/$<
>  endif
>  
>  ifeq ($(V),1)
> @@ -78,4 +82,3 @@ CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float \
>  	  -fno-stack-protector -fno-asynchronous-unwind-tables $(WARNFLAGS)
>  
>  export CC AS LD CLEAN OBJCOPY OBJDUMP STRIP AR RANLIB CFLAGS
> -
>
Thomas Huth Aug. 31, 2021, 9:26 a.m. UTC | #2
On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
> The default .o:.c rule passes a short file name to gcc to when doing
> "make -C <dir>", we do this a lot for all the libraries.
> The file names printed in gcc errors are relative to <dir> and this
> prevents vim from navigating through errors.
> 
> This passes the full file name to gcc to make it print errors with
> absolute path so vim can navigate through errors nicely.
> 
> This makes it optional when V=1 or V=2 is passed.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> 
> Or there is a better way of doing this?
> 
> I find it very annoying to work with ./lib/xxxx as we chdir a lot
> and gcc does not have a flag to print full file names.

This patch broke the compilation of "make js2x" ... thus js2x does not 
compile anymore since more than a year now. Shall we fix it, or shall we 
maybe rather remove the js2x code from the repository?

  Thomas
Alexey Kardashevskiy Aug. 31, 2021, 9:30 a.m. UTC | #3
On 31/08/2021 19:26, Thomas Huth wrote:
> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>> The default .o:.c rule passes a short file name to gcc to when doing
>> "make -C <dir>", we do this a lot for all the libraries.
>> The file names printed in gcc errors are relative to <dir> and this
>> prevents vim from navigating through errors.
>>
>> This passes the full file name to gcc to make it print errors with
>> absolute path so vim can navigate through errors nicely.
>>
>> This makes it optional when V=1 or V=2 is passed.
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>
>> Or there is a better way of doing this?
>>
>> I find it very annoying to work with ./lib/xxxx as we chdir a lot
>> and gcc does not have a flag to print full file names.
> 
> This patch broke the compilation of "make js2x" ... thus js2x does not 
> compile anymore since more than a year now. Shall we fix it, or shall we 
> maybe rather remove the js2x code from the repository?

It does not compile for me neither way - upstream or upstream + reverted 
"make: Define default rule for .c when V=1 or V=2". It should not affect 
building with V=0 anyway, unless I missed something, did I?
Thomas Huth Aug. 31, 2021, 9:38 a.m. UTC | #4
On 31/08/2021 11.30, Alexey Kardashevskiy wrote:
> 
> 
> On 31/08/2021 19:26, Thomas Huth wrote:
>> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>>> The default .o:.c rule passes a short file name to gcc to when doing
>>> "make -C <dir>", we do this a lot for all the libraries.
>>> The file names printed in gcc errors are relative to <dir> and this
>>> prevents vim from navigating through errors.
>>>
>>> This passes the full file name to gcc to make it print errors with
>>> absolute path so vim can navigate through errors nicely.
>>>
>>> This makes it optional when V=1 or V=2 is passed.
>>>
>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>> ---
>>>
>>> Or there is a better way of doing this?
>>>
>>> I find it very annoying to work with ./lib/xxxx as we chdir a lot
>>> and gcc does not have a flag to print full file names.
>>
>> This patch broke the compilation of "make js2x" ... thus js2x does not 
>> compile anymore since more than a year now. Shall we fix it, or shall we 
>> maybe rather remove the js2x code from the repository?
> 
> It does not compile for me neither way - upstream or upstream + reverted 
> "make: Define default rule for .c when V=1 or V=2". It should not affect 
> building with V=0 anyway, unless I missed something, did I?

For me, js2x still compiles with some warnings if I revert the patch. What 
error do you get?
(I'm getting some errors with version.h when running "make distclean" after 
building js2x though)

  Thomas
Alexey Kardashevskiy Aug. 31, 2021, 9:52 a.m. UTC | #5
On 31/08/2021 19:38, Thomas Huth wrote:
> On 31/08/2021 11.30, Alexey Kardashevskiy wrote:
>>
>>
>> On 31/08/2021 19:26, Thomas Huth wrote:
>>> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>>>> The default .o:.c rule passes a short file name to gcc to when doing
>>>> "make -C <dir>", we do this a lot for all the libraries.
>>>> The file names printed in gcc errors are relative to <dir> and this
>>>> prevents vim from navigating through errors.
>>>>
>>>> This passes the full file name to gcc to make it print errors with
>>>> absolute path so vim can navigate through errors nicely.
>>>>
>>>> This makes it optional when V=1 or V=2 is passed.
>>>>
>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>>> ---
>>>>
>>>> Or there is a better way of doing this?
>>>>
>>>> I find it very annoying to work with ./lib/xxxx as we chdir a lot
>>>> and gcc does not have a flag to print full file names.
>>>
>>> This patch broke the compilation of "make js2x" ... thus js2x does 
>>> not compile anymore since more than a year now. Shall we fix it, or 
>>> shall we maybe rather remove the js2x code from the repository?
>>
>> It does not compile for me neither way - upstream or upstream + 
>> reverted "make: Define default rule for .c when V=1 or V=2". It should 
>> not affect building with V=0 anyway, unless I missed something, did I?
> 
> For me, js2x still compiles with some warnings if I revert the patch. 
> What error do you get?
> (I'm getting some errors with version.h when running "make distclean" 
> after building js2x though)


Many "multiple definition of" like this one:

[fstn1-p1 slof]$ make -j 100  js2x
******** Building js2x system ********
  ====== Building clients ======
  ====== Building common libraries ======
  ====== Building llfw ======
  ====== Building slof ======
  ====== Building rtas ======
ld: rtas_board.o:/home/aik/p/slof/board-js2x/include/bmc.h:27: multiple 
definition of `bmc_get_blade_descr'; 
rtas_flash.o:/home/aik/p/slof/board-js2x/include/bmc
.h:27: first defined here

I did "make distclean".

Without revert, I am getting:

         [CC]    rtas_call.o
gcc: error: 
/home/aik/p/slof/board-js2x/rtas//home/aik/p/slof/rtas/rtas_call.c: No 
such file or directory
gcc: fatal error: no input files

which I'll try debugging. Or just remove js2x. Hm.
Thomas Huth Aug. 31, 2021, 9:56 a.m. UTC | #6
On 31/08/2021 11.52, Alexey Kardashevskiy wrote:
> 
> 
> On 31/08/2021 19:38, Thomas Huth wrote:
>> On 31/08/2021 11.30, Alexey Kardashevskiy wrote:
>>>
>>>
>>> On 31/08/2021 19:26, Thomas Huth wrote:
>>>> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>>>>> The default .o:.c rule passes a short file name to gcc to when doing
>>>>> "make -C <dir>", we do this a lot for all the libraries.
>>>>> The file names printed in gcc errors are relative to <dir> and this
>>>>> prevents vim from navigating through errors.
>>>>>
>>>>> This passes the full file name to gcc to make it print errors with
>>>>> absolute path so vim can navigate through errors nicely.
>>>>>
>>>>> This makes it optional when V=1 or V=2 is passed.
>>>>>
>>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>>>> ---
>>>>>
>>>>> Or there is a better way of doing this?
>>>>>
>>>>> I find it very annoying to work with ./lib/xxxx as we chdir a lot
>>>>> and gcc does not have a flag to print full file names.
>>>>
>>>> This patch broke the compilation of "make js2x" ... thus js2x does not 
>>>> compile anymore since more than a year now. Shall we fix it, or shall we 
>>>> maybe rather remove the js2x code from the repository?
>>>
>>> It does not compile for me neither way - upstream or upstream + reverted 
>>> "make: Define default rule for .c when V=1 or V=2". It should not affect 
>>> building with V=0 anyway, unless I missed something, did I?
>>
>> For me, js2x still compiles with some warnings if I revert the patch. What 
>> error do you get?
>> (I'm getting some errors with version.h when running "make distclean" 
>> after building js2x though)
> 
> 
> Many "multiple definition of" like this one:
> 
> [fstn1-p1 slof]$ make -j 100  js2x
> ******** Building js2x system ********
>   ====== Building clients ======
>   ====== Building common libraries ======
>   ====== Building llfw ======
>   ====== Building slof ======
>   ====== Building rtas ======
> ld: rtas_board.o:/home/aik/p/slof/board-js2x/include/bmc.h:27: multiple 
> definition of `bmc_get_blade_descr'; 
> rtas_flash.o:/home/aik/p/slof/board-js2x/include/bmc
> .h:27: first defined here

That sounds like your compiler defaults to -fno-common now ... try to add an 
"extern" in front of that line in bmc.h to see whether that fixes the issue.

  Thomas
Thomas Huth Aug. 31, 2021, 9:58 a.m. UTC | #7
On 31/08/2021 11.56, Thomas Huth wrote:
> On 31/08/2021 11.52, Alexey Kardashevskiy wrote:
>>
>>
>> On 31/08/2021 19:38, Thomas Huth wrote:
>>> On 31/08/2021 11.30, Alexey Kardashevskiy wrote:
>>>>
>>>>
>>>> On 31/08/2021 19:26, Thomas Huth wrote:
>>>>> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>>>>>> The default .o:.c rule passes a short file name to gcc to when doing
>>>>>> "make -C <dir>", we do this a lot for all the libraries.
>>>>>> The file names printed in gcc errors are relative to <dir> and this
>>>>>> prevents vim from navigating through errors.
>>>>>>
>>>>>> This passes the full file name to gcc to make it print errors with
>>>>>> absolute path so vim can navigate through errors nicely.
>>>>>>
>>>>>> This makes it optional when V=1 or V=2 is passed.
>>>>>>
>>>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>>>>> ---
>>>>>>
>>>>>> Or there is a better way of doing this?
>>>>>>
>>>>>> I find it very annoying to work with ./lib/xxxx as we chdir a lot
>>>>>> and gcc does not have a flag to print full file names.
>>>>>
>>>>> This patch broke the compilation of "make js2x" ... thus js2x does not 
>>>>> compile anymore since more than a year now. Shall we fix it, or shall 
>>>>> we maybe rather remove the js2x code from the repository?
>>>>
>>>> It does not compile for me neither way - upstream or upstream + reverted 
>>>> "make: Define default rule for .c when V=1 or V=2". It should not affect 
>>>> building with V=0 anyway, unless I missed something, did I?
>>>
>>> For me, js2x still compiles with some warnings if I revert the patch. 
>>> What error do you get?
>>> (I'm getting some errors with version.h when running "make distclean" 
>>> after building js2x though)
>>
>>
>> Many "multiple definition of" like this one:
>>
>> [fstn1-p1 slof]$ make -j 100  js2x
>> ******** Building js2x system ********
>>   ====== Building clients ======
>>   ====== Building common libraries ======
>>   ====== Building llfw ======
>>   ====== Building slof ======
>>   ====== Building rtas ======
>> ld: rtas_board.o:/home/aik/p/slof/board-js2x/include/bmc.h:27: multiple 
>> definition of `bmc_get_blade_descr'; 
>> rtas_flash.o:/home/aik/p/slof/board-js2x/include/bmc
>> .h:27: first defined here
> 
> That sounds like your compiler defaults to -fno-common now ... try to add an 
> "extern" in front of that line in bmc.h to see whether that fixes the issue.

Or even better: Move the line from bmc.h into board-js2x/rtas/rtas_board.c 
since that's the only spot where it is used.

  Thomas
Alexey Kardashevskiy Sept. 30, 2021, 10:01 a.m. UTC | #8
On 31/08/2021 19:58, Thomas Huth wrote:
> On 31/08/2021 11.56, Thomas Huth wrote:
>> On 31/08/2021 11.52, Alexey Kardashevskiy wrote:
>>>
>>>
>>> On 31/08/2021 19:38, Thomas Huth wrote:
>>>> On 31/08/2021 11.30, Alexey Kardashevskiy wrote:
>>>>>
>>>>>
>>>>> On 31/08/2021 19:26, Thomas Huth wrote:
>>>>>> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>>>>>>> The default .o:.c rule passes a short file name to gcc to when doing
>>>>>>> "make -C <dir>", we do this a lot for all the libraries.
>>>>>>> The file names printed in gcc errors are relative to <dir> and this
>>>>>>> prevents vim from navigating through errors.
>>>>>>>
>>>>>>> This passes the full file name to gcc to make it print errors with
>>>>>>> absolute path so vim can navigate through errors nicely.
>>>>>>>
>>>>>>> This makes it optional when V=1 or V=2 is passed.
>>>>>>>
>>>>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>>>>>> ---
>>>>>>>
>>>>>>> Or there is a better way of doing this?
>>>>>>>
>>>>>>> I find it very annoying to work with ./lib/xxxx as we chdir a lot
>>>>>>> and gcc does not have a flag to print full file names.
>>>>>>
>>>>>> This patch broke the compilation of "make js2x" ... thus js2x does not 
>>>>>> compile anymore since more than a year now. Shall we fix it, or shall 
>>>>>> we maybe rather remove the js2x code from the repository?
>>>>>
>>>>> It does not compile for me neither way - upstream or upstream + reverted 
>>>>> "make: Define default rule for .c when V=1 or V=2". It should not affect 
>>>>> building with V=0 anyway, unless I missed something, did I?
>>>>
>>>> For me, js2x still compiles with some warnings if I revert the patch. 
>>>> What error do you get?
>>>> (I'm getting some errors with version.h when running "make distclean" 
>>>> after building js2x though)
>>>
>>>
>>> Many "multiple definition of" like this one:
>>>
>>> [fstn1-p1 slof]$ make -j 100  js2x
>>> ******** Building js2x system ********
>>>   ====== Building clients ======
>>>   ====== Building common libraries ======
>>>   ====== Building llfw ======
>>>   ====== Building slof ======
>>>   ====== Building rtas ======
>>> ld: rtas_board.o:/home/aik/p/slof/board-js2x/include/bmc.h:27: multiple 
>>> definition of `bmc_get_blade_descr'; 
>>> rtas_flash.o:/home/aik/p/slof/board-js2x/include/bmc
>>> .h:27: first defined here
>>
>> That sounds like your compiler defaults to -fno-common now ... try to add an 
>> "extern" in front of that line in bmc.h to see whether that fixes the issue.
> 
> Or even better: Move the line from bmc.h into board-js2x/rtas/rtas_board.c 
> since that's the only spot where it is used.


I poked this thing a bit.
https://github.com/aik/SLOF-debug/commit/3902aab6fd702aa5c1b0d7c4bd9ac9dd82ae4d71

I has reverted "make: Define default rule for .c when V=1 or V=2" for
now. The error I am getting is "ld: cannot use executable file
'reloc_table.o' as input to a link" which comes from:

[fstn1-p1 rtas]$ ld -melf64ppc -nostdlib -o rtas -T
/home/aik/p/slof/rtas/rtas.lds /home/aik/p/slof/rtas/rtas_entry.o
/home/aik/p/slof/rtas/rtas_common.o /home/aik/p/slof/rtas/reloc.o
/home/aik/p/slof/rtas/rtas_call.o  rtas_flash.o rtas_board.o rtas_pci.o
rtas_out.o rtas_table.o i2c_bmc.o ipmi_oem.o ../llfw/hw.o
../../lib/libc.a ../../lib/libipmi.a
/home/aik/p/slof/rtas/flash/block_lists.o reloc_table.o
ld: cannot use executable file 'reloc_table.o' as input to a link
[fstn1-p1 rtas]$ file reloc_table.o
reloc_table.o: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500,
version 1 (SYSV), statically linked, not stripped

https://git.qemu.org/?p=SLOF.git;a=blob;f=board-js2x/rtas/Makefile;h=5ab5c34c74999dafd354de39b2ee1c7af305ce22;hb=HEAD#l55


I am stuck with this one, ideas how to fix that? Googling suggested "-z
allowexec" which is not recognized by my ld 2.36.1.
Alexey Kardashevskiy Sept. 30, 2021, 10:29 a.m. UTC | #9
On 30/09/2021 20:01, Alexey Kardashevskiy wrote:
> 
> 
> On 31/08/2021 19:58, Thomas Huth wrote:
>> On 31/08/2021 11.56, Thomas Huth wrote:
>>> On 31/08/2021 11.52, Alexey Kardashevskiy wrote:
>>>>
>>>>
>>>> On 31/08/2021 19:38, Thomas Huth wrote:
>>>>> On 31/08/2021 11.30, Alexey Kardashevskiy wrote:
>>>>>>
>>>>>>
>>>>>> On 31/08/2021 19:26, Thomas Huth wrote:
>>>>>>> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>>>>>>>> The default .o:.c rule passes a short file name to gcc to when doing
>>>>>>>> "make -C <dir>", we do this a lot for all the libraries.
>>>>>>>> The file names printed in gcc errors are relative to <dir> and this
>>>>>>>> prevents vim from navigating through errors.
>>>>>>>>
>>>>>>>> This passes the full file name to gcc to make it print errors with
>>>>>>>> absolute path so vim can navigate through errors nicely.
>>>>>>>>
>>>>>>>> This makes it optional when V=1 or V=2 is passed.
>>>>>>>>
>>>>>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>>>>>>> ---
>>>>>>>>
>>>>>>>> Or there is a better way of doing this?
>>>>>>>>
>>>>>>>> I find it very annoying to work with ./lib/xxxx as we chdir a lot
>>>>>>>> and gcc does not have a flag to print full file names.
>>>>>>>
>>>>>>> This patch broke the compilation of "make js2x" ... thus js2x does not 
>>>>>>> compile anymore since more than a year now. Shall we fix it, or shall 
>>>>>>> we maybe rather remove the js2x code from the repository?
>>>>>>
>>>>>> It does not compile for me neither way - upstream or upstream + reverted 
>>>>>> "make: Define default rule for .c when V=1 or V=2". It should not affect 
>>>>>> building with V=0 anyway, unless I missed something, did I?
>>>>>
>>>>> For me, js2x still compiles with some warnings if I revert the patch. 
>>>>> What error do you get?
>>>>> (I'm getting some errors with version.h when running "make distclean" 
>>>>> after building js2x though)
>>>>
>>>>
>>>> Many "multiple definition of" like this one:
>>>>
>>>> [fstn1-p1 slof]$ make -j 100  js2x
>>>> ******** Building js2x system ********
>>>>   ====== Building clients ======
>>>>   ====== Building common libraries ======
>>>>   ====== Building llfw ======
>>>>   ====== Building slof ======
>>>>   ====== Building rtas ======
>>>> ld: rtas_board.o:/home/aik/p/slof/board-js2x/include/bmc.h:27: multiple 
>>>> definition of `bmc_get_blade_descr'; 
>>>> rtas_flash.o:/home/aik/p/slof/board-js2x/include/bmc
>>>> .h:27: first defined here
>>>
>>> That sounds like your compiler defaults to -fno-common now ... try to add an 
>>> "extern" in front of that line in bmc.h to see whether that fixes the issue.
>>
>> Or even better: Move the line from bmc.h into board-js2x/rtas/rtas_board.c 
>> since that's the only spot where it is used.
> 
> 
> I poked this thing a bit.
> https://github.com/aik/SLOF-debug/commit/3902aab6fd702aa5c1b0d7c4bd9ac9dd82ae4d71
> 
> I has reverted "make: Define default rule for .c when V=1 or V=2" for
> now. The error I am getting is "ld: cannot use executable file
> 'reloc_table.o' as input to a link" which comes from:
> 
> [fstn1-p1 rtas]$ ld -melf64ppc -nostdlib -o rtas -T
> /home/aik/p/slof/rtas/rtas.lds /home/aik/p/slof/rtas/rtas_entry.o
> /home/aik/p/slof/rtas/rtas_common.o /home/aik/p/slof/rtas/reloc.o
> /home/aik/p/slof/rtas/rtas_call.o  rtas_flash.o rtas_board.o rtas_pci.o
> rtas_out.o rtas_table.o i2c_bmc.o ipmi_oem.o ../llfw/hw.o
> ../../lib/libc.a ../../lib/libipmi.a
> /home/aik/p/slof/rtas/flash/block_lists.o reloc_table.o
> ld: cannot use executable file 'reloc_table.o' as input to a link
> [fstn1-p1 rtas]$ file reloc_table.o
> reloc_table.o: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500,
> version 1 (SYSV), statically linked, not stripped
> 
> https://git.qemu.org/?p=SLOF.git;a=blob;f=board-js2x/rtas/Makefile;h=5ab5c34c74999dafd354de39b2ee1c7af305ce22;hb=HEAD#l55
> 
> 
> I am stuck with this one, ideas how to fix that? Googling suggested "-z
> allowexec" which is not recognized by my ld 2.36.1.



This helped:

diff --git a/tools/create_reloc_table.sh b/tools/create_reloc_table.sh
index 8cacb742a701..d4790ddff0b0 100755
--- a/tools/create_reloc_table.sh
+++ b/tools/create_reloc_table.sh
@@ -54,7 +54,7 @@ $OBJCOPY -O binary $TMP2.o $TMP2.bin || exit -1
 # Create the relocation table with gen_reloc_table:
 $DIRNAME/gen_reloc_table $TMP1.bin $TMP2.bin reloc_table.bin

-$LD -o reloc_table.o -bbinary reloc_table.bin -e0 || exit -1
+$LD -r -o reloc_table.o -bbinary reloc_table.bin -e0 || exit -1
 $OBJCOPY --rename-section .data=.reloc reloc_table.o reloc_table.o ||
exit -1



continuing digging...
Alexey Kardashevskiy Oct. 1, 2021, 4:54 a.m. UTC | #10
On 30/09/2021 20:29, Alexey Kardashevskiy wrote:
> 
> 
> On 30/09/2021 20:01, Alexey Kardashevskiy wrote:
>>
>>
>> On 31/08/2021 19:58, Thomas Huth wrote:
>>> On 31/08/2021 11.56, Thomas Huth wrote:
>>>> On 31/08/2021 11.52, Alexey Kardashevskiy wrote:
>>>>>
>>>>>
>>>>> On 31/08/2021 19:38, Thomas Huth wrote:
>>>>>> On 31/08/2021 11.30, Alexey Kardashevskiy wrote:
>>>>>>>
>>>>>>>
>>>>>>> On 31/08/2021 19:26, Thomas Huth wrote:
>>>>>>>> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>>>>>>>>> The default .o:.c rule passes a short file name to gcc to when doing
>>>>>>>>> "make -C <dir>", we do this a lot for all the libraries.
>>>>>>>>> The file names printed in gcc errors are relative to <dir> and this
>>>>>>>>> prevents vim from navigating through errors.
>>>>>>>>>
>>>>>>>>> This passes the full file name to gcc to make it print errors with
>>>>>>>>> absolute path so vim can navigate through errors nicely.
>>>>>>>>>
>>>>>>>>> This makes it optional when V=1 or V=2 is passed.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>> Or there is a better way of doing this?
>>>>>>>>>
>>>>>>>>> I find it very annoying to work with ./lib/xxxx as we chdir a lot
>>>>>>>>> and gcc does not have a flag to print full file names.
>>>>>>>>
>>>>>>>> This patch broke the compilation of "make js2x" ... thus js2x does not 
>>>>>>>> compile anymore since more than a year now. Shall we fix it, or shall 
>>>>>>>> we maybe rather remove the js2x code from the repository?
>>>>>>>
>>>>>>> It does not compile for me neither way - upstream or upstream + reverted 
>>>>>>> "make: Define default rule for .c when V=1 or V=2". It should not affect 
>>>>>>> building with V=0 anyway, unless I missed something, did I?
>>>>>>
>>>>>> For me, js2x still compiles with some warnings if I revert the patch. 
>>>>>> What error do you get?
>>>>>> (I'm getting some errors with version.h when running "make distclean" 
>>>>>> after building js2x though)
>>>>>
>>>>>
>>>>> Many "multiple definition of" like this one:
>>>>>
>>>>> [fstn1-p1 slof]$ make -j 100  js2x
>>>>> ******** Building js2x system ********
>>>>>   ====== Building clients ======
>>>>>   ====== Building common libraries ======
>>>>>   ====== Building llfw ======
>>>>>   ====== Building slof ======
>>>>>   ====== Building rtas ======
>>>>> ld: rtas_board.o:/home/aik/p/slof/board-js2x/include/bmc.h:27: multiple 
>>>>> definition of `bmc_get_blade_descr'; 
>>>>> rtas_flash.o:/home/aik/p/slof/board-js2x/include/bmc
>>>>> .h:27: first defined here
>>>>
>>>> That sounds like your compiler defaults to -fno-common now ... try to add an 
>>>> "extern" in front of that line in bmc.h to see whether that fixes the issue.
>>>
>>> Or even better: Move the line from bmc.h into board-js2x/rtas/rtas_board.c 
>>> since that's the only spot where it is used.
>>
>>
>> I poked this thing a bit.
>> https://github.com/aik/SLOF-debug/commit/3902aab6fd702aa5c1b0d7c4bd9ac9dd82ae4d71
>>
>> I has reverted "make: Define default rule for .c when V=1 or V=2" for
>> now. The error I am getting is "ld: cannot use executable file
>> 'reloc_table.o' as input to a link" which comes from:
>>
>> [fstn1-p1 rtas]$ ld -melf64ppc -nostdlib -o rtas -T
>> /home/aik/p/slof/rtas/rtas.lds /home/aik/p/slof/rtas/rtas_entry.o
>> /home/aik/p/slof/rtas/rtas_common.o /home/aik/p/slof/rtas/reloc.o
>> /home/aik/p/slof/rtas/rtas_call.o  rtas_flash.o rtas_board.o rtas_pci.o
>> rtas_out.o rtas_table.o i2c_bmc.o ipmi_oem.o ../llfw/hw.o
>> ../../lib/libc.a ../../lib/libipmi.a
>> /home/aik/p/slof/rtas/flash/block_lists.o reloc_table.o
>> ld: cannot use executable file 'reloc_table.o' as input to a link
>> [fstn1-p1 rtas]$ file reloc_table.o
>> reloc_table.o: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500,
>> version 1 (SYSV), statically linked, not stripped
>>
>> https://git.qemu.org/?p=SLOF.git;a=blob;f=board-js2x/rtas/Makefile;h=5ab5c34c74999dafd354de39b2ee1c7af305ce22;hb=HEAD#l55
>>
>>
>> I am stuck with this one, ideas how to fix that? Googling suggested "-z
>> allowexec" which is not recognized by my ld 2.36.1.
> 
> 
> 
> This helped:
> 
> diff --git a/tools/create_reloc_table.sh b/tools/create_reloc_table.sh
> index 8cacb742a701..d4790ddff0b0 100755
> --- a/tools/create_reloc_table.sh
> +++ b/tools/create_reloc_table.sh
> @@ -54,7 +54,7 @@ $OBJCOPY -O binary $TMP2.o $TMP2.bin || exit -1
>  # Create the relocation table with gen_reloc_table:
>  $DIRNAME/gen_reloc_table $TMP1.bin $TMP2.bin reloc_table.bin
> 
> -$LD -o reloc_table.o -bbinary reloc_table.bin -e0 || exit -1
> +$LD -r -o reloc_table.o -bbinary reloc_table.bin -e0 || exit -1
>  $OBJCOPY --rename-section .data=.reloc reloc_table.o reloc_table.o ||
> exit -1
> 
> 
> 
> continuing digging...


I ended up reverting it. Thanks,


ps. I pushed out everything else in the queue (which is now empty).
Thomas Huth Oct. 1, 2021, 6:57 a.m. UTC | #11
On 01/10/2021 06.54, Alexey Kardashevskiy wrote:
> 
> 
> On 30/09/2021 20:29, Alexey Kardashevskiy wrote:
>>
>>
>> On 30/09/2021 20:01, Alexey Kardashevskiy wrote:
>>>
>>>
>>> On 31/08/2021 19:58, Thomas Huth wrote:
>>>> On 31/08/2021 11.56, Thomas Huth wrote:
>>>>> On 31/08/2021 11.52, Alexey Kardashevskiy wrote:
>>>>>>
>>>>>>
>>>>>> On 31/08/2021 19:38, Thomas Huth wrote:
>>>>>>> On 31/08/2021 11.30, Alexey Kardashevskiy wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>> On 31/08/2021 19:26, Thomas Huth wrote:
>>>>>>>>> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>>>>>>>>>> The default .o:.c rule passes a short file name to gcc to when doing
>>>>>>>>>> "make -C <dir>", we do this a lot for all the libraries.
>>>>>>>>>> The file names printed in gcc errors are relative to <dir> and this
>>>>>>>>>> prevents vim from navigating through errors.
>>>>>>>>>>
>>>>>>>>>> This passes the full file name to gcc to make it print errors with
>>>>>>>>>> absolute path so vim can navigate through errors nicely.
>>>>>>>>>>
>>>>>>>>>> This makes it optional when V=1 or V=2 is passed.
>>>>>>>>>>
>>>>>>>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>>>>>>>>> ---
>>>>>>>>>>
>>>>>>>>>> Or there is a better way of doing this?
>>>>>>>>>>
>>>>>>>>>> I find it very annoying to work with ./lib/xxxx as we chdir a lot
>>>>>>>>>> and gcc does not have a flag to print full file names.
>>>>>>>>>
>>>>>>>>> This patch broke the compilation of "make js2x" ... thus js2x does not
>>>>>>>>> compile anymore since more than a year now. Shall we fix it, or shall
>>>>>>>>> we maybe rather remove the js2x code from the repository?
>>>>>>>>
>>>>>>>> It does not compile for me neither way - upstream or upstream + reverted
>>>>>>>> "make: Define default rule for .c when V=1 or V=2". It should not affect
>>>>>>>> building with V=0 anyway, unless I missed something, did I?
>>>>>>>
>>>>>>> For me, js2x still compiles with some warnings if I revert the patch.
>>>>>>> What error do you get?
>>>>>>> (I'm getting some errors with version.h when running "make distclean"
>>>>>>> after building js2x though)
>>>>>>
>>>>>>
>>>>>> Many "multiple definition of" like this one:
>>>>>>
>>>>>> [fstn1-p1 slof]$ make -j 100  js2x
>>>>>> ******** Building js2x system ********
>>>>>>    ====== Building clients ======
>>>>>>    ====== Building common libraries ======
>>>>>>    ====== Building llfw ======
>>>>>>    ====== Building slof ======
>>>>>>    ====== Building rtas ======
>>>>>> ld: rtas_board.o:/home/aik/p/slof/board-js2x/include/bmc.h:27: multiple
>>>>>> definition of `bmc_get_blade_descr';
>>>>>> rtas_flash.o:/home/aik/p/slof/board-js2x/include/bmc
>>>>>> .h:27: first defined here
>>>>>
>>>>> That sounds like your compiler defaults to -fno-common now ... try to add an
>>>>> "extern" in front of that line in bmc.h to see whether that fixes the issue.
>>>>
>>>> Or even better: Move the line from bmc.h into board-js2x/rtas/rtas_board.c
>>>> since that's the only spot where it is used.
>>>
>>>
>>> I poked this thing a bit.
>>> https://github.com/aik/SLOF-debug/commit/3902aab6fd702aa5c1b0d7c4bd9ac9dd82ae4d71
>>>
>>> I has reverted "make: Define default rule for .c when V=1 or V=2" for
>>> now. The error I am getting is "ld: cannot use executable file
>>> 'reloc_table.o' as input to a link" which comes from:
>>>
>>> [fstn1-p1 rtas]$ ld -melf64ppc -nostdlib -o rtas -T
>>> /home/aik/p/slof/rtas/rtas.lds /home/aik/p/slof/rtas/rtas_entry.o
>>> /home/aik/p/slof/rtas/rtas_common.o /home/aik/p/slof/rtas/reloc.o
>>> /home/aik/p/slof/rtas/rtas_call.o  rtas_flash.o rtas_board.o rtas_pci.o
>>> rtas_out.o rtas_table.o i2c_bmc.o ipmi_oem.o ../llfw/hw.o
>>> ../../lib/libc.a ../../lib/libipmi.a
>>> /home/aik/p/slof/rtas/flash/block_lists.o reloc_table.o
>>> ld: cannot use executable file 'reloc_table.o' as input to a link
>>> [fstn1-p1 rtas]$ file reloc_table.o
>>> reloc_table.o: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500,
>>> version 1 (SYSV), statically linked, not stripped
>>>
>>> https://git.qemu.org/?p=SLOF.git;a=blob;f=board-js2x/rtas/Makefile;h=5ab5c34c74999dafd354de39b2ee1c7af305ce22;hb=HEAD#l55
>>>
>>>
>>> I am stuck with this one, ideas how to fix that? Googling suggested "-z
>>> allowexec" which is not recognized by my ld 2.36.1.
>>
>>
>>
>> This helped:
>>
>> diff --git a/tools/create_reloc_table.sh b/tools/create_reloc_table.sh
>> index 8cacb742a701..d4790ddff0b0 100755
>> --- a/tools/create_reloc_table.sh
>> +++ b/tools/create_reloc_table.sh
>> @@ -54,7 +54,7 @@ $OBJCOPY -O binary $TMP2.o $TMP2.bin || exit -1
>>   # Create the relocation table with gen_reloc_table:
>>   $DIRNAME/gen_reloc_table $TMP1.bin $TMP2.bin reloc_table.bin
>>
>> -$LD -o reloc_table.o -bbinary reloc_table.bin -e0 || exit -1
>> +$LD -r -o reloc_table.o -bbinary reloc_table.bin -e0 || exit -1
>>   $OBJCOPY --rename-section .data=.reloc reloc_table.o reloc_table.o ||
>> exit -1
>>
>>
>>
>> continuing digging...
> 
> 
> I ended up reverting it. Thanks,
> 
> 
> ps. I pushed out everything else in the queue (which is now empty).

Thanks! js2x now compiles fine for me again, too.

Could you maybe now also enable Travis-CI for your repo at github, so that 
we have an indication in the main commit history there to see when things break?

  Thomas
Alexey Kardashevskiy Oct. 2, 2021, 2:32 a.m. UTC | #12
On 01/10/2021 16:57, Thomas Huth wrote:
> On 01/10/2021 06.54, Alexey Kardashevskiy wrote:
>>
>>
>> On 30/09/2021 20:29, Alexey Kardashevskiy wrote:
>>>
>>>
>>> On 30/09/2021 20:01, Alexey Kardashevskiy wrote:
>>>>
>>>>
>>>> On 31/08/2021 19:58, Thomas Huth wrote:
>>>>> On 31/08/2021 11.56, Thomas Huth wrote:
>>>>>> On 31/08/2021 11.52, Alexey Kardashevskiy wrote:
>>>>>>>
>>>>>>>
>>>>>>> On 31/08/2021 19:38, Thomas Huth wrote:
>>>>>>>> On 31/08/2021 11.30, Alexey Kardashevskiy wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 31/08/2021 19:26, Thomas Huth wrote:
>>>>>>>>>> On 11/03/2020 03.37, Alexey Kardashevskiy wrote:
>>>>>>>>>>> The default .o:.c rule passes a short file name to gcc to 
>>>>>>>>>>> when doing
>>>>>>>>>>> "make -C <dir>", we do this a lot for all the libraries.
>>>>>>>>>>> The file names printed in gcc errors are relative to <dir> 
>>>>>>>>>>> and this
>>>>>>>>>>> prevents vim from navigating through errors.
>>>>>>>>>>>
>>>>>>>>>>> This passes the full file name to gcc to make it print errors 
>>>>>>>>>>> with
>>>>>>>>>>> absolute path so vim can navigate through errors nicely.
>>>>>>>>>>>
>>>>>>>>>>> This makes it optional when V=1 or V=2 is passed.
>>>>>>>>>>>
>>>>>>>>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>>>>>>>>>> ---
>>>>>>>>>>>
>>>>>>>>>>> Or there is a better way of doing this?
>>>>>>>>>>>
>>>>>>>>>>> I find it very annoying to work with ./lib/xxxx as we chdir a 
>>>>>>>>>>> lot
>>>>>>>>>>> and gcc does not have a flag to print full file names.
>>>>>>>>>>
>>>>>>>>>> This patch broke the compilation of "make js2x" ... thus js2x 
>>>>>>>>>> does not
>>>>>>>>>> compile anymore since more than a year now. Shall we fix it, 
>>>>>>>>>> or shall
>>>>>>>>>> we maybe rather remove the js2x code from the repository?
>>>>>>>>>
>>>>>>>>> It does not compile for me neither way - upstream or upstream + 
>>>>>>>>> reverted
>>>>>>>>> "make: Define default rule for .c when V=1 or V=2". It should 
>>>>>>>>> not affect
>>>>>>>>> building with V=0 anyway, unless I missed something, did I?
>>>>>>>>
>>>>>>>> For me, js2x still compiles with some warnings if I revert the 
>>>>>>>> patch.
>>>>>>>> What error do you get?
>>>>>>>> (I'm getting some errors with version.h when running "make 
>>>>>>>> distclean"
>>>>>>>> after building js2x though)
>>>>>>>
>>>>>>>
>>>>>>> Many "multiple definition of" like this one:
>>>>>>>
>>>>>>> [fstn1-p1 slof]$ make -j 100  js2x
>>>>>>> ******** Building js2x system ********
>>>>>>>    ====== Building clients ======
>>>>>>>    ====== Building common libraries ======
>>>>>>>    ====== Building llfw ======
>>>>>>>    ====== Building slof ======
>>>>>>>    ====== Building rtas ======
>>>>>>> ld: rtas_board.o:/home/aik/p/slof/board-js2x/include/bmc.h:27: 
>>>>>>> multiple
>>>>>>> definition of `bmc_get_blade_descr';
>>>>>>> rtas_flash.o:/home/aik/p/slof/board-js2x/include/bmc
>>>>>>> .h:27: first defined here
>>>>>>
>>>>>> That sounds like your compiler defaults to -fno-common now ... try 
>>>>>> to add an
>>>>>> "extern" in front of that line in bmc.h to see whether that fixes 
>>>>>> the issue.
>>>>>
>>>>> Or even better: Move the line from bmc.h into 
>>>>> board-js2x/rtas/rtas_board.c
>>>>> since that's the only spot where it is used.
>>>>
>>>>
>>>> I poked this thing a bit.
>>>> https://github.com/aik/SLOF-debug/commit/3902aab6fd702aa5c1b0d7c4bd9ac9dd82ae4d71 
>>>>
>>>>
>>>> I has reverted "make: Define default rule for .c when V=1 or V=2" for
>>>> now. The error I am getting is "ld: cannot use executable file
>>>> 'reloc_table.o' as input to a link" which comes from:
>>>>
>>>> [fstn1-p1 rtas]$ ld -melf64ppc -nostdlib -o rtas -T
>>>> /home/aik/p/slof/rtas/rtas.lds /home/aik/p/slof/rtas/rtas_entry.o
>>>> /home/aik/p/slof/rtas/rtas_common.o /home/aik/p/slof/rtas/reloc.o
>>>> /home/aik/p/slof/rtas/rtas_call.o  rtas_flash.o rtas_board.o rtas_pci.o
>>>> rtas_out.o rtas_table.o i2c_bmc.o ipmi_oem.o ../llfw/hw.o
>>>> ../../lib/libc.a ../../lib/libipmi.a
>>>> /home/aik/p/slof/rtas/flash/block_lists.o reloc_table.o
>>>> ld: cannot use executable file 'reloc_table.o' as input to a link
>>>> [fstn1-p1 rtas]$ file reloc_table.o
>>>> reloc_table.o: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500,
>>>> version 1 (SYSV), statically linked, not stripped
>>>>
>>>> https://git.qemu.org/?p=SLOF.git;a=blob;f=board-js2x/rtas/Makefile;h=5ab5c34c74999dafd354de39b2ee1c7af305ce22;hb=HEAD#l55 
>>>>
>>>>
>>>>
>>>> I am stuck with this one, ideas how to fix that? Googling suggested "-z
>>>> allowexec" which is not recognized by my ld 2.36.1.
>>>
>>>
>>>
>>> This helped:
>>>
>>> diff --git a/tools/create_reloc_table.sh b/tools/create_reloc_table.sh
>>> index 8cacb742a701..d4790ddff0b0 100755
>>> --- a/tools/create_reloc_table.sh
>>> +++ b/tools/create_reloc_table.sh
>>> @@ -54,7 +54,7 @@ $OBJCOPY -O binary $TMP2.o $TMP2.bin || exit -1
>>>   # Create the relocation table with gen_reloc_table:
>>>   $DIRNAME/gen_reloc_table $TMP1.bin $TMP2.bin reloc_table.bin
>>>
>>> -$LD -o reloc_table.o -bbinary reloc_table.bin -e0 || exit -1
>>> +$LD -r -o reloc_table.o -bbinary reloc_table.bin -e0 || exit -1
>>>   $OBJCOPY --rename-section .data=.reloc reloc_table.o reloc_table.o ||
>>> exit -1
>>>
>>>
>>>
>>> continuing digging...
>>
>>
>> I ended up reverting it. Thanks,
>>
>>
>> ps. I pushed out everything else in the queue (which is now empty).
> 
> Thanks! js2x now compiles fine for me again, too.
> 
> Could you maybe now also enable Travis-CI for your repo at github, so 
> that we have an indication in the main commit history there to see when 
> things break?

I did this for https://github.com/aik/SLOF-debug and I am going to push 
it there first.
I do not want to do the same for the main repo as if there is a problem, 
it might be late for fixing it as that repo gets synced to git.qemu.org 
and who knows where else (gitlab?).
diff mbox series

Patch

diff --git a/make.rules b/make.rules
index acbc8ab8ff5c..3dfbb5b136c2 100644
--- a/make.rules
+++ b/make.rules
@@ -49,6 +49,10 @@  ifeq ($(V),0)
 Q		:= @
 MAKEFLAGS	+= --silent
 MAKE		+= -s
+else
+CURDIR=$(shell pwd)
+%.o: %.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $(CURDIR)/$<
 endif
 
 ifeq ($(V),1)
@@ -78,4 +82,3 @@  CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float \
 	  -fno-stack-protector -fno-asynchronous-unwind-tables $(WARNFLAGS)
 
 export CC AS LD CLEAN OBJCOPY OBJDUMP STRIP AR RANLIB CFLAGS
-