[prev in list] [next in list] [prev in thread] [next in thread]
List: pcc-list
Subject: Re: [Pcc] compiling musl with pcc on x86_64
From: u-bzb9 () aetey ! se
Date: 2014-08-24 17:07:34
Message-ID: 20140824170734.GP22945 () example ! net
[Download RAW message or body]
On Sat, Aug 16, 2014 at 05:54:58PM +0200, u-bzb9@aetey.se wrote:
> > >fashion. My experience whatsoever shows that this crt layer is (while not
> > >being your fault) a mess and an obstacle.
> > As I have said a number of times, I would welcome if someone could take care
> > of it.
>
> My time slots are really scarce but I will try to propose changes,
> and also to be as conservative as possible.
I think the attached two small patches would make it straightforwand
for my case - thus at least the crts would no longer remain an obstacle :)
They would also help further users/contributors to understand the meaning
of the different files (otherwise even scanning the Net for knowledge
does not easily enlighten one on this matter).
On the negative side, I was not successful with bootstrapping
pcc+musl on x86_64. I can now compile musl with pcc and link
some programs against it, but linking pcc against musl yields
a cpp which segfaults (running it with wrong arguments yields a usage
message but otherwise the first mmap() is the last syscall before
the crash). Remarkably, the "pcc" driver, also linked to the same
musl instance, seems to work. Linking pcc to a musl compiled with
gcc makes the problem go away, which means there is some miscompilation
of musl by pcc. Recompilation of pcc by pcc works otherwise well.
What makes me even more sad, when Debian gdb tries to read symbols from
the faulty cpp, it segfaults itself :)
I will be happy to test any updates but will not pursue this matter myself.
Regards,
Rune
["patch.pcc-libs.startup-files" (text/plain)]
--- csu/README.ori 2009-08-14 04:17:08.000000000 +0200
+++ csu/README 2014-08-24 13:21:58.784989299 +0200
@@ -1,18 +1,27 @@
-$Id: README,v 1.4 2009/08/14 02:17:08 gmcgarry Exp $
+$Id$
OS-dependent and target-dependent:
+To be provided by the target's libc:
+(the corresponding code included in this archive is mere incomplete
+examples, can be possibly useful to replace the platform-provided
+ones, but only on exceptionally broken platforms)
+
crt0.o startup code for programs (maybe compiled -static)
-crt1.o startup code for programs compiled -dynamic (if necessary)
-gcrt1.o profiling startup code for programs (maybe compiled -dynamic)
+crt1.o a different flavour of startup code (iff the platform needs
+ this in certain platform-specific situations)
+gcrt[01].o the corresponding profiling startup code for programs
crti.o beginning of _init() and _fini() functions (inside .init section)
crtn.o end of _init() and _fini() functions (inside .fini section)
-OS-dependent, but target-independent:
+To be provided by the compiler, needed if and only if support for
+the following (not included in the standard C) feature is desired:
crtbegin.o support for calling global ctors/dtors
crtend.o end of the ctor/dtor lists
-crtbeginT.o + for static binary (if necessary)
-crtendT.o + for static binary (if necessary)
-crtbeginS.o + for shared library (if necessary)
-crtendS.o + for shared library (if necessary)
+if a difference from crtbegin.o/crtend.o is enforced by the platform:
+crtbeginT.o + for static binary
+crtendT.o + for static binary
+crtbeginS.o + for shared library
+crtendS.o + for shared library
+
--- csu/linux/Makefile.ori 2014-04-18 11:12:33.000000000 +0200
+++ csu/linux/Makefile 2014-08-24 13:34:35.263768614 +0200
@@ -6,8 +6,10 @@
CFLAGS = -I$(SRCDIR)/$(MACH) -I$(SRCDIR) -Wall -Wstrict-prototypes -Wmissing-prototypes
-OBJS = crt0.o crt1.o gcrt1.o crti.o crtn.o crtbegin.o crtend.o \
- crtbeginS.o crtendS.o
+# to be able to support the non-standard ctors/dtors a la gcc:
+OBJS = crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o crtendT.o
+
+COPYOBJS = crtbegin.o crtend.o
all: $(OBJS)
@@ -26,21 +28,37 @@
crtn.o: $(MACH)/crtn.c
$(CC) -O $(CFLAGS) -c -o $@ $<
+# this platform works fine with a single version
+# of the files for all linking cases
+
crtbegin.o: crtbegin.c
- $(CC) -O $(CFLAGS) -c -o $@ $<
+ $(CC) -O $(CFLAGS) -fPIC -c -o $@ $<
crtend.o: crtend.c
- $(CC) -O $(CFLAGS) -c -o $@ $<
+ $(CC) -O $(CFLAGS) -fPIC -c -o $@ $<
+
+crtbeginS.o: crtbegin.o
+ ln -s crtbegin.o crtbeginS.o
+
+crtendS.o: crtend.o
+ ln -s crtend.o crtendS.o
-crtbeginS.o: crtbegin.c
- $(CC) -O $(CFLAGS) -fpic -c -o $@ $<
+crtbeginT.o: crtbegin.o
+ ln -s crtbegin.o crtbeginT.o
-crtendS.o: crtend.c
- $(CC) -O $(CFLAGS) -fpic -c -o $@ $<
+crtendT.o: crtend.o
+ ln -s crtend.o crtendT.o
install:
mkdir -p ${DESTDIR}$(PCCLIBDIR)
- cp $(OBJS) ${DESTDIR}$(PCCLIBDIR)
+ cp $(COPYOBJS) ${DESTDIR}$(PCCLIBDIR)
+ ( set -e;\
+ cd ${DESTDIR}$(PCCLIBDIR);\
+ ln -s crtbegin.o crtbeginS.o;\
+ ln -s crtend.o crtendS.o;\
+ ln -s crtbegin.o crtbeginT.o;\
+ ln -s crtend.o crtendT.o;\
+ )
clean:
rm -f $(OBJS)
["patch.pcc.startup-files" (text/plain)]
--- cc/cc/cc.c.ori 2014-08-24 12:31:17.397896961 +0200
+++ cc/cc/cc.c 2014-08-24 13:06:26.622493377 +0200
@@ -153,35 +153,44 @@
/* crt files using pcc default names */
+ /* crtbegin/end are used and provided by pcc */
+ /* for gcc compatibility, namely for */
+ /* __attribute__((constructor))/((destructor)) */
#ifndef CRTBEGIN_S
-#define CRTBEGIN_S "crtbeginS.o"
-#endif
+#define CRTBEGIN_S "crtbeginS.o" /* is linked into PIE executables, */
+#endif /* differs from crtbegin.o only if architecture */
+ /* postulates different files for PIE executables */
#ifndef CRTEND_S
-#define CRTEND_S "crtendS.o"
-#endif
+#define CRTEND_S "crtendS.o" /* is linked into PIE executables, */
+#endif /* differs from crtend.o only if architecture */
+ /* postulates different files for PIE executables */
#ifndef CRTBEGIN_T
-#define CRTBEGIN_T "crtbeginT.o"
-#endif
+#define CRTBEGIN_T "crtbeginT.o" /* is linked into static executables, */
+#endif /* differs from crtbegin.o only if architecture */
+ /* postulates different files for static executables */
#ifndef CRTEND_T
-#define CRTEND_T "crtendT.o"
-#endif
-#ifndef CRTBEGIN
-#define CRTBEGIN "crtbegin.o"
+#define CRTEND_T "crtendT.o" /* is linked into static executables, */
+#endif /* differs from crtend.o only if architecture */
+ /* postulates different files for static executables */
+#ifndef CRTBEGIN
+#define CRTBEGIN "crtbegin.o" /* is linked into shared executables, */
#endif
#ifndef CRTEND
-#define CRTEND "crtend.o"
+#define CRTEND "crtend.o" /* is linked into shared executables, */
#endif
+ /* the crt files listed below are to be provided */
+ /* by libc, not by pcc */
#ifndef CRTI
-#define CRTI "crti.o"
+#define CRTI "crti.o" /* .init section with _init symbol */
#endif
#ifndef CRTN
-#define CRTN "crtn.o"
+#define CRTN "crtn.o" /* .fini section with _fini symbol */
#endif
#ifndef CRT0
-#define CRT0 "crt0.o"
+#define CRT0 "crt0.o" /* the main libc-specific startup file */
#endif
#ifndef GCRT0
-#define GCRT0 "gcrt0.o"
+#define GCRT0 "gcrt0.o" /* corresponding profiling startup file */
#endif
/* preprocessor stuff */
@@ -204,6 +213,10 @@
#ifndef DEFLIBDIRS /* default library search paths */
#define DEFLIBDIRS { "/usr/lib/", 0 }
#endif
+/* the sequences below like "-lpcc", "-lc", "-lpcc" are meant */
+/* to hopefully resolve all crossreferences between the libc */
+/* and the compiler-specific runtime support library */
+/* (no general guarantee but works in practice) */
#ifndef DEFLIBS /* default libraries included */
#define DEFLIBS { "-lpcc", "-lc", "-lpcc", 0 }
#endif
_______________________________________________
Pcc mailing list
Pcc@lists.ludd.ltu.se
http://lists.ludd.ltu.se/cgi-bin/mailman/listinfo/pcc
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic