3b2aa532bf
way: first they are compiled to assembly, then some sed'ing is done on the assembly, and lastly the assembly is compiled to an object file. This last step is done using ${CC}, and not ${AS}, because when the compiler is clang, it outputs directives that are too advanced for our old gas. So we use clang's integrated assembler instead. (When the compiler is gcc, it just calls gas, and nothing is different, except one extra fork.) However, in the .s to .o rules in lib/csu/$ARCH/Makefile, I still passed CFLAGS to the compiler, instead of ACFLAGS, which are specifically for compiling .s files. In case you are using '-g' for debug info anywhere in your CFLAGS, it causes the .s files to already contain debug information in the assembly itself. In the next step, the .s files are also compiled using '-g', and if the compiler is clang, it complains: "error: input can't have .file dwarf directives when -g is used to generate dwarf debug info for assembly code". Fix this by using ${ACFLAGS} for compiling the .s files instead. Reported by: jasone MFC after: 1 week
52 lines
1.3 KiB
Makefile
52 lines
1.3 KiB
Makefile
# $FreeBSD$
|
|
|
|
.PATH: ${.CURDIR}/../common
|
|
|
|
SRCS= crti.S crtn.S
|
|
FILES= ${SRCS:N*.h:R:S/$/.o/g} gcrt1.o crt1.o Scrt1.o
|
|
FILESOWN= ${LIBOWN}
|
|
FILESGRP= ${LIBGRP}
|
|
FILESMODE= ${LIBMODE}
|
|
FILESDIR= ${LIBDIR}
|
|
CFLAGS+= -I${.CURDIR}/../common \
|
|
-I${.CURDIR}/../../libc/include
|
|
CLEANFILES= ${FILES} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o
|
|
CLEANFILES+= crt1_c.s gcrt1_c.s Scrt1_c.s
|
|
|
|
# See the comment in lib/csu/common/crtbrand.c for the reason crt1_c.c is not
|
|
# directly compiled to .o files.
|
|
|
|
gcrt1_c.s: crt1_c.c
|
|
${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1_c.c
|
|
sed ${SED_FIX_NOTE} ${.TARGET}
|
|
|
|
gcrt1_c.o: gcrt1_c.s
|
|
${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1_c.s
|
|
|
|
gcrt1.o: gcrt1_c.o crt1_s.o
|
|
${LD} ${LDFLAGS} -o gcrt1.o -r crt1_s.o gcrt1_c.o
|
|
|
|
crt1_c.s: crt1_c.c
|
|
${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1_c.c
|
|
sed ${SED_FIX_NOTE} ${.TARGET}
|
|
|
|
crt1_c.o: crt1_c.s
|
|
${CC} ${ACFLAGS} -c -o ${.TARGET} crt1_c.s
|
|
|
|
crt1.o: crt1_c.o crt1_s.o
|
|
${LD} ${LDFLAGS} -o crt1.o -r crt1_s.o crt1_c.o
|
|
objcopy --localize-symbol _start1 crt1.o
|
|
|
|
Scrt1_c.s: crt1_c.c
|
|
${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1_c.c
|
|
sed ${SED_FIX_NOTE} ${.TARGET}
|
|
|
|
Scrt1_c.o: Scrt1_c.s
|
|
${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1_c.s
|
|
|
|
Scrt1.o: Scrt1_c.o crt1_s.o
|
|
${LD} ${LDFLAGS} -o Scrt1.o -r crt1_s.o Scrt1_c.o
|
|
objcopy --localize-symbol _start1 Scrt1.o
|
|
|
|
.include <bsd.prog.mk>
|