Here's a patch to klcc.in from klibc-0.202. The context: I have an
application, managed with GNU automake/autoconf. Packagers should be
able to build the application with klibc if available, with plain gcc
otherwise, as follows:
$ cd ~/klibc-0.202
$ ... make linux symlink
$ make bindir=$HOME/local/bin \
mandir=$HOME/local/man \
INSTALLDIR=$HOME/local \
SHLIBDIR=$HOME/local/shlib \
install
$ cd ~/myapp
$ ./configure --prefix=$HOME/local CC=$HOME/local/bin/klcc
It turns out klcc needs a few tweaks to function as a drop-in gcc
replacement, specifically:
* support -D -U -I options
* fix klcc -c myapp.o myapp.c
* fix klcc -o myapp myapp.o
Regards,
Erik
diff -urN klibc-0.202/klcc.in klibc-0.202-new/klcc.in
--- klibc-0.202/klcc.in 2005-03-02 03:32:17.000000000 +0100
+++ klibc-0.202-new/klcc.in 2005-03-02 16:43:12.000000000 +0100
@@ -20,6 +20,7 @@
my ($file) = @_;
return "c" if ( $file =~ /\.c$/ );
+ return "obj" if ( $file =~ /\.o$/ );
return "c-header" if ( $file =~ /\.h$/ );
return "cpp-output" if ( $file =~ /\.i$/ );
return "c++-cpp-output" if ( $file =~ /\.ii$/ );
@@ -109,7 +110,7 @@
} elsif ( $a =~ /^-Wl,(.*)$/ ) {
# -Wl used to pass options to the linker
push(@ldopt, split(/,/, $1));
- } elsif ( $a =~ /^-([fmwWQdO]|std=|ansi|pedantic)/ ) {
+ } elsif ( $a =~ /^-([fmwWQdODUI]|std=|ansi|pedantic)/ ) {
# Options to gcc
push(@ccopt, $a);
} elsif ( $a =~ /^-[gp]/ ) {
@@ -124,6 +125,7 @@
push(@ccopt, $a);
$save_temps = 1;
} elsif ( $a =~ '^-([cSE])$' ) {
+ push(@ccopt, $a);
$operation = $1;
} elsif ( $a eq '-shared' ) {
$shared = 1;
Erik van Konijnenburg wrote:> > * support -D -U -I options > * fix klcc -c myapp.o myapp.c > * fix klcc -o myapp myapp.o >With the second one, do you mean klcc -c myapp.c or klcc -c -o myapp.o myapp.c ? Either which way, thanks for testing it out. -hpa
This patch addresses three issues in klcc:
* lets klcc define __KLIBC__.
It's also defined in the klibc <stddef.h>, but we cannot
rely on stddef being included in every sourcefile of
every application that wants to use klibc.
* supports the option -include,
for example 'gcc -include config.h expr.c'.
This option is used in the ash Makefile.
* when running 'klcc -o app main.o lib.o'
only the last file was passed to the link-editor.
Regards,
Erik
--- klibc-0.204-pristine/klcc.in 2005-03-02 21:33:00.000000000 +0100
+++ klibc-0.204-work/klcc.in 2005-03-02 23:40:02.000000000 +0100
@@ -81,7 +81,7 @@
# Begin parsing options.
#
-@ccopt = ();
+@ccopt = ('-D__KLIBC__');
@ldopt = ();
@files = (); # List of files
@@ -117,6 +117,9 @@
# (-DFOO) or a disjoint argument (-D FOO)
push(@ccopt, $a);
push(@ccopt, shift(@ARGV)) if ( $2 eq '' );
+ } elsif ( $a eq '-include' ) {
+ push(@ccopt, $a);
+ push(@ccopt, shift(@ARGV));
} elsif ( $a =~ /^-[gp]/ ) {
# Debugging options to gcc *and* ld
push(@ccopt, $a);
@@ -163,8 +166,8 @@
} else {
@outopt = ('-o', $output || 'a.out');
+ @objs = ();
foreach $f ( @files ) {
- @objs = ();
@rmobjs = ();
if ( $flang{$f} eq 'obj' ) {
push(@objs, $f);
Possibly Parallel Threads
- [klibc:master] klcc: Treat CC, LD, STRIP as multiple words
- [PATCH] support the gcc parameter --param in klcc
- [PATCH] klcc --version is -V because -v is --verbose already (unbreak -v)
- [PATCH 1/1] Modify --param support to include additional option
- [PATCH] klcc: Remove the need for bash