Re: [Tinycc-devel] NetBSD/aarch64 Unknown relocation type for got: 299

2021-01-10 Thread Herman ten Brugge via Tinycc-devel

On 1/7/21 10:53 PM, grischka wrote:

Herman ten Brugge wrote:

I just commited an update.


Thanks ;)


Also a bit more explanation would be nice.  Does it introduce text
relocations or does it try to avoid them?  What is the benefit, under
what scenario, and is it desirable always or should it maybe depend
on a -fPIE switch or like that?


As far as I know all targets generate -FPIC code by default.

For bsd support I recently applied patches to use the GOT table 
correctly.

Also netbsd requires that DT_TEXTREL is not set. So I applied patches
for that also.


I just wondered whether it adds some overhead that for most cases is
not really necessary when executables are loaded at fixed addresses
without need for relocations to its own symbols at runtime really.

Some systems may require position independent executables but even
GCC I think needs a configure option to make them by default.

Also there is still the ARM-PE target, aka wince.  I don't know if
it's still functional (or ever was) though.


I first bench marked the code before committing. The slowdown was
between 2% and 5% depending on how much global data is used.
I also saw that incrementing a variable in global memory does
2 times a pointer load.
So:

int a;
int main(void) { a++; return 0; }

results in arm code:

 :
   0:   e1a0c00d    mov ip, sp
   4:   e92d5800    push    {fp, ip, lr}
   8:   e1a0b00d    mov fp, sp
   c:   e1a0    nop ; (mov r0, r0)
  10:   e59fe000    ldr lr, [pc]    ; 18 
  14:   ea00    b   1c 
  18:   fff4    ;  instruction: 
0xfff4

  1c:   e08ee00f    add lr, lr, pc
  20:   e59ee000    ldr lr, [lr]
  24:   e59e    ldr r0, [lr]
  28:   e1a01000    mov r1, r0
  2c:   e281    add r0, r0, #1
  30:   e59fe000    ldr lr, [pc]    ; 38 
  34:   ea00    b   3c 
  38:   fff4    ;  instruction: 
0xfff4

  3c:   e08ee00f    add lr, lr, pc
  40:   e59ee000    ldr lr, [lr]
  44:   e58e    str r0, [lr]
  48:   e3a0    mov r0, #0
  4c:   e89ba800    ldm fp, {fp, sp, pc}

The lr register loaded at line 24 is not reused and is fetched again.
If this for example is fixed the slowdown would be much less.

The only target that does now uses DT_TEXTREL is i386. But this requires
a complete rewrite.

I made some simple patches to the i386 code but quickly came to the
conclusion that converting this target is not feasible.
So I will not update this target.

    Herman


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] NetBSD/aarch64 Unknown relocation type for got: 299

2021-01-07 Thread grischka

Herman ten Brugge wrote:

I just commited an update.


Thanks ;)


Also a bit more explanation would be nice.  Does it introduce text
relocations or does it try to avoid them?  What is the benefit, under
what scenario, and is it desirable always or should it maybe depend
on a -fPIE switch or like that?


As far as I know all targets generate -FPIC code by default.

For bsd support I recently applied patches to use the GOT table correctly.
Also netbsd requires that DT_TEXTREL is not set. So I applied patches
for that also.


I just wondered whether it adds some overhead that for most cases is
not really necessary when executables are loaded at fixed addresses
without need for relocations to its own symbols at runtime really.

Some systems may require position independent executables but even
GCC I think needs a configure option to make them by default.

Also there is still the ARM-PE target, aka wince.  I don't know if
it's still functional (or ever was) though.

--- grischka


The only target that does now uses DT_TEXTREL is i386. But this requires
a complete rewrite.

Herman



___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] NetBSD/aarch64 Unknown relocation type for got: 299

2021-01-05 Thread grischka

Herman ten Brugge via Tinycc-devel wrote:

I fixed this one also. But the problem is that below commits are gone.
This happended after te commit 'arm-asm: Implement branch to label


Hi Herman,

Would you consider to review the "text relocation for arm" commit,
eventually?

Such copy & paste portions not only look ugly but also make it more
difficult for other people to understand the structure and to make
changes if they want to.

Also a bit more explanation would be nice.  Does it introduce text
relocations or does it try to avoid them?  What is the benefit, under
what scenario, and is it desirable always or should it maybe depend
on a -fPIE switch or like that?

Thanks,

--- grischka


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] NetBSD/aarch64 Unknown relocation type for got: 299

2021-01-05 Thread Herman ten Brugge via Tinycc-devel

Help,

Can you help me to recover the commits and give advice to Danny 
Milosavljevic

to use git correctly.

Thanks,

    Herman

On 1/5/21 2:40 PM, Danny Milosavljevic wrote:

Hi,

On Tue, 5 Jan 2021 07:25:33 +0100
Herman ten Brugge  wrote:


I fixed this one also. But the problem is that below commits are gone.
This happended after te commit 'arm-asm: Implement branch to label
'

The git workflow I'm using for this project is unusual for me--I'm not sure
I do the steps the right way.

I always work on the same local branch, "arm-asm".

To push changes, I do:

git checkout mob
git pull --rebase
git checkout arm-asm
git rebase mob
git push -f ssh://m...@repo.or.cz/srv/git/tinycc.git arm-asm:mob

The last form I've never used ever before anywhere else--and I use git every 
day.
But that's what the description in tinycc said.

Anyway, could be that the stuff above broke something, or not.  Just wanted to
make sure we can figure out what happened.

Should I instead create a new branch every time?

(Can I set the upstream link ("-u") so I don't have to do the last line with 
URL?
How would that look?)



___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] NetBSD/aarch64 Unknown relocation type for got: 299

2021-01-04 Thread Herman ten Brugge via Tinycc-devel

I fixed this one also. But the problem is that below commits are gone.
This happended after te commit 'arm-asm: Implement branch to label 
'


    Herman

commit 94714f046b423b6ee10471575082419a280ac663
Author: herman ten brugge 
Date:   Mon Jan 4 21:22:18 2021 +0100

    text relocation for arm

commit e5c3d1dc705f4c1b4ecccf795f97fa409914ea2e
Author: herman ten brugge 
Date:   Mon Jan 4 18:14:09 2021 +0100

    disable nan test for clang

commit 29d8871d6196819caff83b4359e22cc3655bc234
Author: Michael Matz 
Date:   Mon Jan 4 03:58:22 2021 +0100

    Implement proper floating point negation

    Using "-0.0 - x" still isn't enough if x is a NaN, so bite the bullet
    and implement sign-bit flipping via memory.  (It's usually not too bad,
    the -0.0-x method also uses memory for the floating point constant).

    This way is at least shorter than implementing a new top-level 
operation

    for all backends (a negate) that would be unary.

commit 4c9516941c459ba2294c3d3f7bd3a81af33ec618
Author: herman ten brugge 
Date:   Sun Jan 3 20:12:34 2021 +0100

    Fix wine

    After removing uint64_t from stddef.h the tcc_libm.h now needs to
    include stdint.h

commit 33d5a9fadb50e4163209bb27abcfe9d0ef451051
Author: herman ten brugge 
Date:   Sun Jan 3 19:14:53 2021 +0100

    add arm64 relocs


On 1/5/21 7:06 AM, Christian Jullien wrote:


Yet another reloc error with clang, on NetBSD aarch64 this time

uname -a

NetBSD arm64 9.1 NetBSD 9.1 (GENERIC64) #0: Sun Oct 18 19:24:30 UTC 
2020 
mkre...@mkrepro.netbsd.org:/usr/src/sys/arch/evbarm/compile/GENERIC64 
evbarm





OK

 dlltest 

Hello World

 dlltest with PIC 

tcc: error: Unknown relocation type for got: 299

make[2]: *** [Makefile:166: dlltest] Error 1

 abitest-cc 



___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] NetBSD/aarch64 Unknown relocation type for got: 299

2021-01-04 Thread Christian Jullien
Yet another reloc error with clang, on NetBSD aarch64 this time

 

uname -a

NetBSD arm64 9.1 NetBSD 9.1 (GENERIC64) #0: Sun Oct 18 19:24:30 UTC 2020
mkre...@mkrepro.netbsd.org:/usr/src/sys/arch/evbarm/compile/GENERIC64 evbarm

 

./configure --strip-binaries --cc=clang --prefix=/home/jullien/tinycc/static

Binary directory/home/jullien/tinycc/static/bin

TinyCC directory/home/jullien/tinycc/static/lib/tcc

Library directory   /home/jullien/tinycc/static/lib

Include directory   /home/jullien/tinycc/static/include

Manual directory/home/jullien/tinycc/static/share/man

Info directory  /home/jullien/tinycc/static/share/info

Doc directory   /home/jullien/tinycc/static/share/doc

Source path /home/jullien/tinycc

C compiler  clang (7.0)

Target OS   Linux

CPU aarch64

Triplet aarch64-linux-gnu

Config  strip

Creating config.mak and config.h

clang -o tcc.o -c tcc.c -DCONFIG_TRIPLET="\"aarch64-linux-gnu\""
-DTCC_TARGET_AR
M64-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement
-fno-strict-al
iasing -fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare
-Wno-unused-
result -Wno-string-plus-int -I.

clang -o libtcc.o -c libtcc.c -DCONFIG_TRIPLET="\"aarch64-linux-gnu\""
-DTCC_TAR
GET_ARM64-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement
-fno-str
ict-aliasing -fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare
-Wno-u
nused-result -Wno-string-plus-int -I.

clang -DC2STR conftest.c -o c2str.exe && ./c2str.exe include/tccdefs.h
tccdefs_.
h

clang -o tccpp.o -c tccpp.c -DCONFIG_TRIPLET="\"aarch64-linux-gnu\""
-DTCC_TARGE
T_ARM64-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement
-fno-stric
t-aliasing -fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare
-Wno-unu
sed-result -Wno-string-plus-int -I.

clang -o tccgen.o -c tccgen.c -DCONFIG_TRIPLET="\"aarch64-linux-gnu\""
-DTCC_TAR
GET_ARM64-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement
-fno-str
ict-aliasing -fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare
-Wno-u
nused-result -Wno-string-plus-int -I.

clang -o tccelf.o -c tccelf.c -DCONFIG_TRIPLET="\"aarch64-linux-gnu\""
-DTCC_TAR
GET_ARM64-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement
-fno-str
ict-aliasing -fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare
-Wno-u
nused-result -Wno-string-plus-int -I.

clang -o tccasm.o -c tccasm.c -DCONFIG_TRIPLET="\"aarch64-linux-gnu\""
-DTCC_TAR
GET_ARM64-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement
-fno-str
ict-aliasing -fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare
-Wno-u
nused-result -Wno-string-plus-int -I.

clang -o tccrun.o -c tccrun.c -DCONFIG_TRIPLET="\"aarch64-linux-gnu\""
-DTCC_TAR
GET_ARM64-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement
-fno-str
ict-aliasing -fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare
-Wno-u
nused-result -Wno-string-plus-int -I.

clang -o arm64-gen.o -c arm64-gen.c -DCONFIG_TRIPLET="\"aarch64-linux-gnu\""
-DT
CC_TARGET_ARM64-DONE_SOURCE=0 -Wall -O2
-Wdeclaration-after-statement -f
no-strict-aliasing -fheinous-gnu-extensions -Wno-pointer-sign
-Wno-sign-compare
-Wno-unused-result -Wno-string-plus-int -I.

clang -o arm64-link.o -c arm64-link.c
-DCONFIG_TRIPLET="\"aarch64-linux-gnu\"" -
DTCC_TARGET_ARM64-DONE_SOURCE=0 -Wall -O2
-Wdeclaration-after-statement
-fno-strict-aliasing -fheinous-gnu-extensions -Wno-pointer-sign
-Wno-sign-compar
e -Wno-unused-result -Wno-string-plus-int -I.

clang -o arm64-asm.o -c arm64-asm.c -DCONFIG_TRIPLET="\"aarch64-linux-gnu\""
-DT
CC_TARGET_ARM64-DONE_SOURCE=0 -Wall -O2
-Wdeclaration-after-statement -f
no-strict-aliasing -fheinous-gnu-extensions -Wno-pointer-sign
-Wno-sign-compare
-Wno-unused-result -Wno-string-plus-int -I.

ar rcs libtcc.a libtcc.o tccpp.o tccgen.o tccelf.o tccasm.o tccrun.o
arm64-gen.o
arm64-link.o arm64-asm.o

clang -o tcc tcc.o libtcc.a -lm -lpthread -ldl  -s

make[1]: Entering directory '/home/jullien/tinycc/lib'

../tcc -c lib-arm64.c -o lib-arm64.o -B.. -I..

../tcc -c fetch_and_add_arm64.S -o fetch_and_add_arm64.o -B.. -I..

../tcc -c dsohandle.c -o dsohandle.o -B.. -I..

../tcc -ar rcs ../libtcc1.a lib-arm64.o fetch_and_add_arm64.o dsohandle.o

../tcc -c bt-exe.c -o ../bt-exe.o -B.. -I..

../tcc -c bt-log.c -o ../bt-log.o -B.. -I..

../tcc -c bcheck.c -o ../bcheck.o -B.. -I.. -g

make[1]: Leaving directory '/home/jullien/tinycc/lib'

perl ./texi2pod.pl tcc-doc.texi tcc-doc.pod

pod2man --section=1 --center="Tiny C Compiler" --release="0.9.27"
tcc-doc.pod >t
cc.1 && rm -f tcc-doc.pod

make[1]: Entering directory '/home/jullien/tinycc/tests'

 hello-exe 

Hello World

 hello-run 

Hello World

 libtest 

Hello World!

fib(32) = 2178309

add(32, 64) = 96

 libtest_mt 

running fib with mixed calls

  1 2 3 5 8 13 21 34 55 89 144 233