aboutsummaryrefslogtreecommitdiffstats
path: root/lang
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2009-12-06 23:08:37 +0800
committerluigi <luigi@FreeBSD.org>2009-12-06 23:08:37 +0800
commitec7129c79b30fd3674c1ed827b746c36a56f6998 (patch)
tree4bc612832aec558cb7d3d231cd0868c42fa9057c /lang
parentddc449c1d32e55df4b85953c0d1091a495f5005f (diff)
downloadfreebsd-ports-gnome-ec7129c79b30fd3674c1ed827b746c36a56f6998.tar.gz
freebsd-ports-gnome-ec7129c79b30fd3674c1ed827b746c36a56f6998.tar.zst
freebsd-ports-gnome-ec7129c79b30fd3674c1ed827b746c36a56f6998.zip
Update files/README.tccelf files/patch-libtcc.c to reflect some
fixes i made recently. Add files/patch-z1-preproc which implements -include, -M and some related preprocessing macros to improve portability Bump portrevision accordingly Should close PR/141185
Diffstat (limited to 'lang')
-rw-r--r--lang/tcc/Makefile2
-rw-r--r--lang/tcc/files/README.tccelf46
-rw-r--r--lang/tcc/files/patch-libtcc.c32
-rw-r--r--lang/tcc/files/patch-z1-preproc223
4 files changed, 264 insertions, 39 deletions
diff --git a/lang/tcc/Makefile b/lang/tcc/Makefile
index 48ea5830efaf..2b95d892e104 100644
--- a/lang/tcc/Makefile
+++ b/lang/tcc/Makefile
@@ -7,7 +7,7 @@
PORTNAME= tcc
PORTVERSION= 0.9.25
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= lang
MASTER_SITES= ${MASTER_SITE_SAVANNAH}
MASTER_SITE_SUBDIR= tinycc
diff --git a/lang/tcc/files/README.tccelf b/lang/tcc/files/README.tccelf
index 40a75d8af23a..6e991757bae2 100644
--- a/lang/tcc/files/README.tccelf
+++ b/lang/tcc/files/README.tccelf
@@ -1,17 +1,11 @@
+The patches in this directory include some updates to tcc 0.9.25.
+Some of them have been committed in the main tcc repository so
+we will not need them in future updates.
-I think i have managed to solve the problem and produce
-almost valid elf files on FreeBSD. The two patches attached
-should go in ports/tcc/files (patch-libtcc.c replaces
-the existing one with the same name) and bumping PORTREVISION
-should complete the job. I can do the commit myself if the
-maintainer has no time.
+In particular:
-The patches address a few problems (trying to explain to the
-best of my knowledge; i am not very familiar with ELF and
-the FreeBSD ELF conventions):
-
-1. ELF file format
- tcc produces an ELF executable which is good for linux but
+1. ELF file format (merged upstream)
+ tcc 0.9.25 produces an ELF executable which is good for linux but
not for FreeBSD. It misses the PHDR section which is almost
mandatory for shared executables, puts in the .dynsym section
some relocation info that FreeBSD expects to be in .got,
@@ -23,21 +17,23 @@ the FreeBSD ELF conventions):
loader through an environment variable (this is important to
debug tcc).
-2. predefined macros
+ The resulting elf file is still not 100% correct -- if you strip it,
+ the program will not run (presumably there is some dangling reference).
+ Other than that, program do seem to run correctly.
+2. predefined macros (partially merged upstream)
patch-libtcc.c adds/fixes some predefined macros when compiling
on FreeBSD: these are __FreeBSD__ and the usual set of
__i386__ and __unix__ variants.
- It also sets __INTEL_COMPILER so we can grab the __aligned
- macro from cdefs.h , otherwise many programs would fail
-
-The resulting elf file is still not 100% correct -- if you strip it,
-the program will not run (presumably there is some dangling reference).
-Other than that, program do seem to run correctly.
-
-I am going to submit the patch upstream to see if the maintainers
-want to integrate it
-
- cheers
- luigi
+ It also #defines __builtin_inline(x,y), __PRETTY_FUNCTION__,
+ __CC_SUPPORTS___INLINE, __aligned(x), __packed that are used
+ in cdefs.h and by several user programs.
+ Note that tcc recognises the __aligned__ and __packed__
+ attributes but does not honor them.
+
+3. -include, -M and other preprocessor directives
+ patch-z1-preproc (name chosen because it must be applied after
+ the other two) implements -include, -M (and related options),
+ and makes tcc ignore -isystem and -std= which are often used
+ to build code.
diff --git a/lang/tcc/files/patch-libtcc.c b/lang/tcc/files/patch-libtcc.c
index 2fd6d59ee674..660e87845435 100644
--- a/lang/tcc/files/patch-libtcc.c
+++ b/lang/tcc/files/patch-libtcc.c
@@ -24,28 +24,34 @@ diff -ubwr ./libtcc.c ../../work.2/tcc-0.9.25/libtcc.c
tcc_define_symbol(s, "__STDC__", NULL);
tcc_define_symbol(s, "__STDC_VERSION__", "199901L");
#if defined(TCC_TARGET_I386)
-- tcc_define_symbol(s, "__i386__", NULL);
-+ tcc_define_symbol(s, "__i386__", "1");
-+ tcc_define_symbol(s, "__i386", "1");
-+ tcc_define_symbol(s, "i386", "1");
+ tcc_define_symbol(s, "__i386__", NULL);
++ tcc_define_symbol(s, "__i386", NULL); /* NULL defaults to "1" */
++ tcc_define_symbol(s, "i386", NULL);
#endif
#if defined(TCC_TARGET_X86_64)
tcc_define_symbol(s, "__x86_64__", NULL);
-@@ -1802,8 +1812,15 @@
- #ifdef TCC_TARGET_PE
- tcc_define_symbol(s, "_WIN32", NULL);
+@@ -1802,6 +1812,14 @@
#else
-- tcc_define_symbol(s, "__unix__", NULL);
-- tcc_define_symbol(s, "__unix", NULL);
-+ tcc_define_symbol(s, "__unix__", "1");
-+ tcc_define_symbol(s, "__unix", "1");
-+ tcc_define_symbol(s, "unix", "1");
+ tcc_define_symbol(s, "__unix__", NULL);
+ tcc_define_symbol(s, "__unix", NULL);
++ tcc_define_symbol(s, "unix", NULL);
+#if defined(__FreeBSD__)
+#define str(s) #s
+ tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
-+ tcc_define_symbol(s, "__INTEL_COMPILER", "1");
+#undef str
++ tcc_define_symbol(s, "__aligned(x)", "__attribute__((__aligned__(x)))");
++ tcc_define_symbol(s, "__packed", "__attribute__((packed))");
+#endif
#if defined(__linux)
tcc_define_symbol(s, "__linux__", NULL);
tcc_define_symbol(s, "__linux", NULL);
+@@ -1834,6 +1841,9 @@
+ tcc_define_symbol(s, "__TINYC__", NULL);
+
+ /* tiny C & gcc defines */
++ tcc_define_symbol(s, "__CC_SUPPORTS___INLINE", NULL);
++ tcc_define_symbol(s, "__builtin_inline(x,y)", "(x)");
++ tcc_define_symbol(s, "__PRETTY_FUNCTION__", "__FUNCTION__");
+ tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned int");
+ tcc_define_symbol(s, "__PTRDIFF_TYPE__", "int");
+ #ifdef TCC_TARGET_PE
diff --git a/lang/tcc/files/patch-z1-preproc b/lang/tcc/files/patch-z1-preproc
new file mode 100644
index 000000000000..fbc0a04d00b9
--- /dev/null
+++ b/lang/tcc/files/patch-z1-preproc
@@ -0,0 +1,223 @@
+diff -ubwr --exclude .svn ./libtcc.c /usr/ports-luigi/tcc/work/tcc-0.9.25/libtcc.c
+--- ./libtcc.c 2009-12-06 14:35:51.000000000 +0100
++++ /usr/ports-luigi/tcc/work/tcc-0.9.25/libtcc.c 2009-12-06 14:34:34.000000000 +0100
+@@ -1108,7 +1108,15 @@
+ bf->fd = fd;
+ bf->buf_ptr = bf->buffer;
+ bf->buf_end = bf->buffer;
++ if (s1->include_len <= 0) {
+ bf->buffer[0] = CH_EOB; /* put eob symbol */
++ } else { /* add the list of -include */
++ if (s1->include_len >= sizeof(bf->buffer))
++ error("too many '-include directives %s\n", s1->include_buf);
++ memcpy(bf->buf_ptr, s1->include_buf, s1->include_len);
++ bf->buffer[s1->include_len] = CH_EOB; /* put eob symbol */
++ s1->include_len = -s1->include_len;
++ }
+ pstrcpy(bf->filename, sizeof(bf->filename), filename);
+ #ifdef _WIN32
+ normalize_slashes(bf->filename);
+@@ -1945,6 +1955,9 @@
+ if (ext[0])
+ ext++;
+
++ /* enable -include on each new file */
++ if (s1->include_len < 0)
++ s1->include_len = -s1->include_len;
+ /* open the file */
+ saved_file = file;
+ file = tcc_open(s1, filename);
+@@ -2121,7 +2134,9 @@
+ {
+ char buf[1024];
+
+- s->output_type = output_type;
++ s->output_type = output_type & 7;
++ s->mode_m = output_type & 8;
++ output_type = s->output_type;
+
+ if (!s->nostdinc) {
+ /* default include paths */
+diff -ubwr --exclude .svn ./tcc.c /usr/ports-luigi/tcc/work/tcc-0.9.25/tcc.c
+--- ./tcc.c 2009-05-18 16:27:06.000000000 +0200
++++ /usr/ports-luigi/tcc/work/tcc-0.9.25/tcc.c 2009-12-06 13:42:09.000000000 +0100
+@@ -66,6 +66,7 @@
+ static int multiple_files;
+ static int print_search_dirs;
+ static int output_type;
++static int mode_m;
+ static int reloc_output;
+ static const char *outfile;
+ static int do_bench = 0;
+@@ -111,6 +112,10 @@
+ TCC_OPTION_w,
+ TCC_OPTION_pipe,
+ TCC_OPTION_E,
++ TCC_OPTION_M, /* -M and related options */
++ TCC_OPTION_std, /* -std= */
++ TCC_OPTION_isystem, /* -isystem x */
++ TCC_OPTION_include, /* -include x */
+ };
+
+ static const TCCOption tcc_options[] = {
+@@ -148,6 +153,10 @@
+ { "w", TCC_OPTION_w, 0 },
+ { "pipe", TCC_OPTION_pipe, 0},
+ { "E", TCC_OPTION_E, 0},
++ { "M", TCC_OPTION_M, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
++ { "std=", TCC_OPTION_std, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
++ { "isystem", TCC_OPTION_isystem, TCC_OPTION_HAS_ARG },
++ { "include", TCC_OPTION_include, TCC_OPTION_HAS_ARG },
+ { NULL },
+ };
+
+@@ -399,10 +408,45 @@
+ }
+ }
+ break;
++ case TCC_OPTION_include:
++ {
++ int len = strlen(optarg) + s->include_len + 12; /* #include ""\n */
++ char *dst;
++ s->include_buf = (s->include_len == 0) ?
++ tcc_malloc(len + 1) :
++ tcc_realloc(s->include_buf, len + 1);
++ dst = s->include_buf + s->include_len;
++ sprintf(dst, "#include \"%s\"\n", optarg);
++ s->include_len = len; /* exclude '\0' */
++ }
++ break;
++ case TCC_OPTION_isystem:
++ break; /* ignore isystem */
++ case TCC_OPTION_std:
++ break; /* ignore -std= */
++ case TCC_OPTION_M:
++ mode_m |= 8;
++ if (optarg[0] == '\0') /* plain -M */
++ ;
++ else if (optarg[0] == 'D') /* add output filename */
++ ;
++ else if (optarg[0] == 'F') { /* output filename */
++ if (optind < argc)
++ outfile = argv[optind++];
++ } else if (optarg[0] == 'T') { /* target filename */
++ if (optind < argc)
++ s->target_name = argv[optind++];
++ } else if (optarg[0] == 'P') { /* phony filename */
++ ;
++ } else {
++ goto l_default;
++ }
++ /* FALLTHROUGH */
+ case TCC_OPTION_E:
+ output_type = TCC_OUTPUT_PREPROCESS;
+ break;
+ default:
++l_default:
+ if (s->warn_unsupported) {
+ unsupported_option:
+ warning("unsupported option '%s'", r);
+@@ -502,7 +546,7 @@
+ start_time = getclock_us();
+ }
+
+- tcc_set_output_type(s, output_type);
++ tcc_set_output_type(s, output_type | mode_m);
+
+ /* compile or add each files or library */
+ for(i = 0; i < nb_files && ret == 0; i++) {
+diff -ubwr --exclude .svn ./tcc.h /usr/ports-luigi/tcc/work/tcc-0.9.25/tcc.h
+--- ./tcc.h 2009-05-18 16:27:06.000000000 +0200
++++ /usr/ports-luigi/tcc/work/tcc-0.9.25/tcc.h 2009-12-06 13:28:32.000000000 +0100
+@@ -475,6 +475,10 @@
+
+ /* output file for preprocessing */
+ FILE *outfile;
++ int mode_m; /* tcc -M */
++ const char *target_name; /* set with -MT or -MQ */
++ char *include_buf; /* -include ... */
++ int include_len; /* length of -include ... */
+
+ /* for tcc_relocate */
+ int runtime_added;
+diff -ubwr --exclude .svn ./tccpp.c /usr/ports-luigi/tcc/work/tcc-0.9.25/tccpp.c
+--- ./tccpp.c 2009-05-18 16:27:06.000000000 +0200
++++ /usr/ports-luigi/tcc/work/tcc-0.9.25/tccpp.c 2009-12-05 15:18:13.000000000 +0100
+@@ -2897,6 +2897,7 @@
+ Sym *define_start;
+ BufferedFile *file_ref;
+ int token_seen, line_ref;
++ const char *base_file;
+
+ preprocess_init(s1);
+ define_start = define_stack;
+@@ -2908,6 +2909,15 @@
+ line_ref = 0;
+ file_ref = NULL;
+
++ base_file = file->filename;
++ if (s1->mode_m) {
++ int l = strlen(base_file);
++ if (s1->target_name)
++ fprintf(s1->outfile, "%s: %s", s1->target_name, base_file);
++ else
++ fprintf(s1->outfile, "%.*s.o: %s", l-2, base_file, base_file);
++ }
++
+ for (;;) {
+ next();
+ if (tok == TOK_EOF) {
+@@ -2919,16 +2929,25 @@
+ token_seen = 0;
+ } else if (!token_seen) {
+ int d = file->line_num - line_ref;
++ if (s1->mode_m) {
++ if (file != file_ref && file->filename != base_file &&
++ !search_cached_include(s1, '>', file->filename))
++ fprintf(s1->outfile, " \\\n %s", file->filename);
++ } else {
+ if (file != file_ref || d < 0 || d >= 8)
+ fprintf(s1->outfile, "# %d \"%s\"\n", file->line_num, file->filename);
+ else
+ while (d)
+ fputs("\n", s1->outfile), --d;
++ }
+ line_ref = (file_ref = file)->line_num;
+ token_seen = 1;
+ }
++ if (!s1->mode_m)
+ fputs(get_tok_str(tok, &tokc), s1->outfile);
+ }
++ if (s1->mode_m)
++ fprintf(s1->outfile, "\n");
+ free_defines(define_start);
+ return 0;
+ }
+diff -ubwr --exclude .svn ./tcc.c /usr/ports-luigi/tcc/work/tcc-0.9.25/tcc.c
+--- ./tcc.c 2009-12-06 15:42:02.000000000 +0100
++++ /usr/ports-luigi/tcc/work/tcc-0.9.25/tcc.c 2009-12-06 15:42:40.000000000 +0100
+@@ -40,8 +40,11 @@
+ "Preprocessor options:\n"
+ " -E preprocess only\n"
+ " -Idir add include path 'dir'\n"
++ " -include f #include file 'f' before everything else\n"
+ " -Dsym[=val] define 'sym' with value 'val'\n"
+ " -Usym undefine 'sym'\n"
++ " -M generate include list. Implies -E\n"
++ " -MT file use 'file' as target for -M.\n"
+ "Linker options:\n"
+ " -Ldir add library path 'dir'\n"
+ " -llib link with dynamic or static library 'lib'\n"
+@@ -58,6 +61,12 @@
+ #ifdef CONFIG_TCC_BACKTRACE
+ " -bt N show N callers in stack traces\n"
+ #endif
++ "Ignored options (for gcc compatibility):\n"
++ " -std=X \n"
++ " -MD name\n"
++ " -MP\n"
++ " -isystem dir\n"
++
+ );
+ }
+