Kirill Smelkov
93de8d8038
tcc: Explicitly require -l<lib> for libraries
...
Previously it was possible to specify e.g. -q<lib> and still link with
lib. Avoid such behaviour by checking for '-l' instead of '-l.'
2010-06-21 20:49:46 +04:00
Kirill Smelkov
0c928da96d
tcc: Draft suppoprt for -MD/-MF options
...
In build systems, this is used to automatically collect target
dependencies, e.g.
---- 8< (hello.c) ----
#include "hello.h"
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
$ tcc -MD -c hello.c # -> hello.o, hello.d
$ cat hello.d
hello.o : \
hello.c \
hello.h \
/usr/include/stdio.h \
/usr/include/features.h \
/usr/include/bits/predefs.h \
/usr/include/sys/cdefs.h \
/usr/include/bits/wordsize.h \
/usr/include/gnu/stubs.h \
/usr/include/bits/wordsize.h \
/usr/include/gnu/stubs-32.h \
/home/kirr/local/tcc/lib/tcc/include/stddef.h \
/usr/include/bits/types.h \
/usr/include/bits/wordsize.h \
/usr/include/bits/typesizes.h \
/usr/include/libio.h \
/usr/include/_G_config.h \
/usr/include/wchar.h \
/home/kirr/local/tcc/lib/tcc/include/stdarg.h \
/usr/include/bits/stdio_lim.h \
/usr/include/bits/sys_errlist.h \
NOTE: gcc supports -MD only for .c -> .o, but in tcc, we generate
dependencies for whatever action is being taken. E.g. for .c -> exe, the
result will be:
$ tcc -MD -o hello hello.c # -> hello, hello.d
hello: \
/usr/lib/crt1.o \
/usr/lib/crti.o \
hello.c \
hello.h \
/usr/include/stdio.h \
/usr/include/features.h \
/usr/include/bits/predefs.h \
/usr/include/sys/cdefs.h \
/usr/include/bits/wordsize.h \
/usr/include/gnu/stubs.h \
/usr/include/bits/wordsize.h \
/usr/include/gnu/stubs-32.h \
/home/kirr/local/tcc/lib/tcc/include/stddef.h \
/usr/include/bits/types.h \
/usr/include/bits/wordsize.h \
/usr/include/bits/typesizes.h \
/usr/include/libio.h \
/usr/include/_G_config.h \
/usr/include/wchar.h \
/home/kirr/local/tcc/lib/tcc/include/stdarg.h \
/usr/include/bits/stdio_lim.h \
/usr/include/bits/sys_errlist.h \
/usr/lib/libc.so \
/lib/libc.so.6 \
/usr/lib/ld-linux.so.2 \
/lib/ld-linux.so.2 \
/usr/lib/libc_nonshared.a \
/lib/libc.so.6 \
/usr/lib/libc_nonshared.a \
/home/kirr/local/tcc/lib/tcc/libtcc1.a \
/usr/lib/crtn.o \
So tcc dependency generator is a bit more clever than one used in gcc :)
Also, I've updated TODO and Changelog (in not-yet-released section).
v2:
(Taking inputs from grischka and me myself)
- put code to generate deps file into a function.
- used tcc_fileextension() instead of open-coding
- generate deps only when compilation/preprocessing was successful
v3:
- use pstrcpy instead of snprintf(buf, sizeof(buf), "%s", ...)
2010-06-21 20:49:02 +04:00
Kirill Smelkov
bdae4a59c3
tcc: Refactor "compute default outfile name" into libtcc function
...
Since for upcoming -MD support default _compile_ output file be needed
even when preprocesssing (tcc -E), let's move this code out of one
particular condition block into a common function, so that we could use
it in deps generation code too.
v2:
- As suggested by grischka, moved into libtcc function instead of always
computing near start of main()
- There is a FIXME about how to return result - I don't want to bother
callers with allocating temp buffers, not I think it will be a good
idea to hook default_target to TCCState. Clearly, I'm to used to
things like std::string and python's str...
2010-06-20 21:36:47 +04:00
Kirill Smelkov
a919a373da
Add input files/libs and reloc_output switch to TCCState
...
files[0], and reloc_outpu will be needed for (upcoming in the next
patch) "compute default outfile name" refactored into libtcc function.
Also, since for symmetry and from libification point of view, it makes
some sense to also put all information about what was given as input to
compilation into TCCState, let's not only put files[0], but all
files and all libraries given explicitely by user.
One point: I've used bitfield for reloc_output & trimmed down
output_type to 8 bits so that TCCState stays the same in size, and also
access to output_type is (hopefully) is not slower.
By the way -- as of today, sizeof(TCCState) on i686-pc-linux-gnu is 2884
bytes...
2010-06-20 20:30:01 +04:00
Kirill Smelkov
66b54af8ea
tcc: Fix typo in error (it's '%s', not '%s)
2010-06-16 16:51:55 +04:00
Detlef Riekenberg
34dabe496f
libtcc: Detect (but ignore) -init and -fini for -Wl
...
--
By by ... Detlef
2010-04-05 22:56:33 +02:00
Detlef Riekenberg
78e83d8761
libtcc: Allow multiple options for -Wl separated with ','
...
I moved the code to libtcc to prepare for a later tiny_ld
--
By by ... Detlef
2010-04-05 21:21:58 +02:00
Detlef Riekenberg
62ba135228
Add support for --help
2010-01-26 22:58:48 +01:00
Detlef Riekenberg
2650584ac4
Recognize -Wl,-Bsymbolic
...
Without -Bsymbolic, a symbol/function in a *.so can be overridden
by a symbol/function in the main module.
That is the default search order, but not supported by tcc.
With -Bsymbolic, the linker tries to resolve a symbol/function in
the current module first.
The loader in tcc implements this search order.
We do not distinguish -Bsymbolic and -Bsymbolic-function
--
By by ... Detlef
2010-01-26 22:55:14 +01:00
grischka
88a3ccab9f
allow tcc be build from separate objects
...
If you want that, run: make NOTALLINONE=1
2009-12-20 01:53:49 +01:00
grischka
e81569bc70
tcc: add "-Wl,-rpath=path" option (library search path)
2009-12-19 22:16:20 +01:00
Frederic Feret
b7d7af4fa2
ARM: first support for arm-pe target
2009-11-13 18:09:00 +01:00
Frederic Feret
2f73e42d87
various fixes and new options for PE format
2009-11-13 18:09:00 +01:00
grischka
b08dfb8273
tcc: optionally build using libtcc
2009-07-18 22:08:01 +02:00
grischka
94ae3984b0
tccpe: set tcc_lib_path from DLL
2009-07-18 22:07:33 +02:00
grischka
0085c648f6
bcheck: restore malloc hooks when done
2009-07-18 21:54:47 +02:00
grischka
c4b7e77bbe
accept option -x <lang>
2009-06-17 02:11:27 +02:00
grischka
67aebdd5b7
enable making tcc using libtcc
2009-05-11 18:46:02 +02:00
grischka
0a35f9d66e
move static prototypes to libtcc.c
2009-05-11 18:45:56 +02:00
grischka
f9181416f6
move some global variables into TCCState
2009-05-11 18:45:44 +02:00
grischka
5c6509578e
make tcc from tcc.c and libtcc from libtcc.c
2009-05-05 20:41:17 +02:00
grischka
b8f6e1ae30
move minor things from libtcc.c to other files
2009-05-05 20:30:39 +02:00
grischka
9dc9cbf319
move libtcc interface and helper functions to libtcc.c
2009-05-05 20:18:53 +02:00
grischka
0d1ed74102
move parser/generator to tccgen.c
2009-05-05 20:18:10 +02:00
grischka
805990b94e
move preprocessor to tccpp.c
2009-05-05 20:17:49 +02:00
grischka
ae37bd5abc
move declarations to tcc.h
2009-05-05 20:17:26 +02:00
grischka
e9e89ad699
enable backtrace only when it's supported
2009-04-18 18:39:27 +02:00
grischka
d165e87340
libtcc: new api tcc_set_lib_path
2009-04-18 15:08:03 +02:00
grischka
73ba078d2f
tcc_relocate: return error and remove unused code
2009-04-18 15:08:03 +02:00
Shinichiro Hamaji
d36fea34e3
Call relocate_sym() before we return the offset, so user doesn't need to check the return value twice.
2009-04-18 15:08:03 +02:00
grischka
dd5630ff95
tcc -E: fix pasting empty tokens
...
/* test case */
#define t(x,y,z) x ## y ## z
int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
t(10,,), t(,11,), t(,,12), t(,,) };
tcc -E: xpected result:
int j[] = { 123, 45, 67, 89,
10, 11, 12, };
2009-04-18 15:08:02 +02:00
grischka
0f0ed4a8bf
tcc -E: preserve spaces, alternative solution
...
/* test case */
#define STR(x) #x
#define MKSTR(x) STR(x)
MKSTR(-A-)
MKSTR(+ B +)
tcc -E: expected result:
"-A-"
"+ B +"
2009-04-18 15:08:02 +02:00
grischka
90697c4c56
CONFIG_TCC_STATIC: add dummy for dlclose
2009-04-18 15:08:02 +02:00
grischka
d62301b050
avoid warning uninitialized
2009-04-18 15:08:02 +02:00
Shinichiro Hamaji
9a7173bf69
x86-64: Fix tcc -run. We need extra memory for PLT and GOT.
...
Size of the extra buffer is too large for now.
2009-04-18 15:08:02 +02:00
grischka
e6ba81b012
get rid of 8 bytes memory leak
2009-04-18 15:08:02 +02:00
grischka
b1697be691
change tcc_add/get_symbol to use void*
2009-04-18 15:08:02 +02:00
grischka
795f67428e
alternative int tcc_relocate(TCCState *s1, void *ptr);
2009-04-18 15:08:02 +02:00
grischka
9a8b2912ed
TOK_builtin_malloc: alternative solution
2009-04-18 15:08:02 +02:00
Shinichiro Hamaji
39a4b859d4
x86-64: Fix cast from integers to pointers.
...
Now,
./tcc -run -DTCC_TARGET_X86_64 tcc.c -run tcctest.c
works!
2009-04-18 15:08:02 +02:00
Shinichiro Hamaji
83fd36333a
Fixes for issues I've just found/introduced to x86 TCC.
...
- Cast from pointer to long long makes TCC output an error. Use cast to int before we apply shift operation for a pointer value.
- Removed test cases for casts from pointer to char/short because they produce warning.
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
be43c8e0ed
x86-64: Cast from 64bit pointer to long long must not generate movslq.
2009-04-18 15:08:01 +02:00
grischka
a9c78d04f2
win32: accept uppercase filename suffixes
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
b879ffa193
x86-64: There can be valid addresses which is greater than 0xc0000000.
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
de3f0a46fe
Fix for x86-64: The first and second arguments of memcpy must be pointers.
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
2e9b57b6d0
Fix silly typos in the previous change.
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
9fe28b610e
x86-64: Make ABI for long double compatible with GCC.
...
- Now we use x87's stack top the long double return values.
- Add rc_fret and reg_fret, wrapper functions for RC_FRET and REG_FRET.
- Add a test case to check if strto* works OK.
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
fcf2e5981f
x86-64: Combine buffers of sections before we call tcc_run().
...
- Now we can run tcc -run tcc.c successfully, though there are some bugs.
- Remove jmp_table and got_table and use text_section for got and plt entries.
- Combine buffers in tcc_relocate().
- Use R_X86_64_64 instead of R_X86_64_32 for R_DATA_32 (now the name R_DATA_32 is inappropriate...).
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
830b7533c9
Generate PIC code so that we can create shared objects properly.
...
- Add got_table in TCCState. This approach is naive and the distance between executable code and GOT can be longer than 32bit.
- Handle R_X86_64_GOTPCREL properly. We use got_table for TCC_OUTPUT_MEMORY case for now.
- Fix load() and store() so that they access global variables via GOT.
2009-04-18 15:08:01 +02:00
grischka
6c10429aa5
check for absolute include paths
...
Suggested by Sandor Zsolt <narkoskatona@yahoo.com>
2009-04-18 15:07:28 +02:00