Skip to content

Full bootstrap? #1

@Dawid33

Description

@Dawid33

I really like this project, really amazing job.

In the 05/README.md it says to you can compile tcc with the tcc0 binary which works but when I run that command with the -MD flag the resulting file says that it uses a lot of system level headers / libraries. I think the musl build is more self contained so I built that and attempted to build tcc using tcc0 with the -nostdinc and -nostdlib flags without much luck.

The contents of tcc1.d after adding -MD (./tcc0 -MD tcc.c -o tcc1)
tcc1: \
 /usr/lib/x86_64-linux-gnu/crt1.o \
 /usr/lib/x86_64-linux-gnu/crti.o \
 tcc.c \
 tcc.h \
 config.h \
 /usr/include/stdlib.h \
 /usr/include/bits/libc-header-start.h \
 /usr/include/features.h \
 /usr/include/features-time64.h \
 /usr/include/bits/wordsize.h \
 /usr/include/bits/timesize.h \
 /usr/include/bits/wordsize.h \
 /usr/include/stdc-predef.h \
 /usr/include/sys/cdefs.h \
 /usr/include/bits/wordsize.h \
 /usr/include/bits/long-double.h \
 /usr/include/gnu/stubs.h \
 /usr/include/gnu/stubs-64.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/bits/waitflags.h \
 /usr/include/bits/waitstatus.h \
 /usr/include/bits/floatn.h \
 /usr/include/bits/floatn-common.h \
 /usr/include/bits/long-double.h \
 /usr/include/bits/types/locale_t.h \
 /usr/include/bits/types/__locale_t.h \
 /usr/include/sys/types.h \
 /usr/include/bits/types.h \
 /usr/include/bits/wordsize.h \
 /usr/include/bits/timesize.h \
 /usr/include/bits/wordsize.h \
 /usr/include/bits/typesizes.h \
 /usr/include/bits/time64.h \
 /usr/include/bits/types/clock_t.h \
 /usr/include/bits/types/clockid_t.h \
 /usr/include/bits/types/time_t.h \
 /usr/include/bits/types/timer_t.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/bits/stdint-intn.h \
 /usr/include/endian.h \
 /usr/include/bits/endian.h \
 /usr/include/bits/endianness.h \
 /usr/include/bits/byteswap.h \
 /usr/include/bits/uintn-identity.h \
 /usr/include/sys/select.h \
 /usr/include/bits/select.h \
 /usr/include/bits/types/sigset_t.h \
 /usr/include/bits/types/__sigset_t.h \
 /usr/include/bits/types/struct_timeval.h \
 /usr/include/bits/types/struct_timespec.h \
 /usr/include/bits/pthreadtypes.h \
 /usr/include/bits/thread-shared-types.h \
 /usr/include/bits/pthreadtypes-arch.h \
 /usr/include/bits/wordsize.h \
 /usr/include/bits/atomic_wide_counter.h \
 /usr/include/bits/struct_mutex.h \
 /usr/include/bits/struct_rwlock.h \
 /usr/include/alloca.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/bits/stdlib-float.h \
 /usr/include/stdio.h \
 /usr/include/bits/libc-header-start.h \
 ../tcc-bootstrap/include/stddef.h \
 ../tcc-bootstrap/include/stdarg.h \
 /usr/include/bits/types/__fpos_t.h \
 /usr/include/bits/types/__mbstate_t.h \
 /usr/include/bits/types/__fpos64_t.h \
 /usr/include/bits/types/__FILE.h \
 /usr/include/bits/types/FILE.h \
 /usr/include/bits/types/struct_FILE.h \
 /usr/include/bits/types/cookie_io_functions_t.h \
 /usr/include/bits/stdio_lim.h \
 /usr/include/string.h \
 /usr/include/bits/libc-header-start.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/strings.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/errno.h \
 /usr/include/bits/errno.h \
 /usr/include/linux/errno.h \
 /usr/include/asm/errno.h \
 /usr/include/asm-generic/errno.h \
 /usr/include/asm-generic/errno-base.h \
 /usr/include/bits/types/error_t.h \
 /usr/include/math.h \
 /usr/include/bits/libc-header-start.h \
 /usr/include/bits/math-vector.h \
 /usr/include/bits/libm-simd-decl-stubs.h \
 /usr/include/bits/flt-eval-method.h \
 /usr/include/bits/fp-logb.h \
 /usr/include/bits/fp-fast.h \
 /usr/include/bits/mathcalls-helper-functions.h \
 /usr/include/bits/mathcalls.h \
 /usr/include/bits/mathcalls-helper-functions.h \
 /usr/include/bits/mathcalls.h \
 /usr/include/bits/mathcalls-helper-functions.h \
 /usr/include/bits/mathcalls.h \
 /usr/include/bits/mathcalls.h \
 /usr/include/bits/mathcalls.h \
 /usr/include/bits/mathcalls.h \
 /usr/include/bits/mathcalls.h \
 /usr/include/bits/mathcalls-narrow.h \
 /usr/include/bits/mathcalls-narrow.h \
 /usr/include/bits/mathcalls-narrow.h \
 /usr/include/bits/mathcalls-narrow.h \
 /usr/include/bits/mathcalls-narrow.h \
 /usr/include/bits/mathcalls-narrow.h \
 /usr/include/bits/mathcalls-narrow.h \
 /usr/include/bits/mathcalls-narrow.h \
 /usr/include/bits/mathcalls-narrow.h \
 /usr/include/bits/iscanonical.h \
 ../tcc-bootstrap/include/float.h \
 /usr/include/fcntl.h \
 /usr/include/bits/fcntl.h \
 /usr/include/bits/fcntl-linux.h \
 /usr/include/bits/types/struct_iovec.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/linux/falloc.h \
 /usr/include/bits/stat.h \
 /usr/include/bits/struct_stat.h \
 /usr/include/setjmp.h \
 /usr/include/bits/setjmp.h \
 /usr/include/bits/wordsize.h \
 /usr/include/bits/types/struct___jmp_buf_tag.h \
 /usr/include/time.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/bits/time.h \
 /usr/include/bits/timex.h \
 /usr/include/bits/types/struct_tm.h \
 /usr/include/bits/types/struct_itimerspec.h \
 /usr/include/unistd.h \
 /usr/include/bits/posix_opt.h \
 /usr/include/bits/environments.h \
 /usr/include/bits/wordsize.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/bits/confname.h \
 /usr/include/bits/getopt_posix.h \
 /usr/include/bits/getopt_core.h \
 /usr/include/bits/unistd_ext.h \
 /usr/include/sys/time.h \
 libtcc.h \
 elf.h \
 stab.h \
 stab.def \
 x86_64-gen.c \
 x86_64-link.c \
 tcctok.h \
 libtcc.c \
 tccpp.c \
 tcctok.h \
 tccgen.c \
 tccelf.c \
 tccrun.c \
 /usr/include/sys/mman.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/bits/mman.h \
 /usr/include/bits/mman-map-flags-generic.h \
 /usr/include/bits/mman-linux.h \
 /usr/include/bits/mman-shared.h \
 /usr/include/signal.h \
 /usr/include/bits/signum-generic.h \
 /usr/include/bits/signum-arch.h \
 /usr/include/bits/types/sig_atomic_t.h \
 /usr/include/bits/types/siginfo_t.h \
 /usr/include/bits/wordsize.h \
 /usr/include/bits/types/__sigval_t.h \
 /usr/include/bits/siginfo-arch.h \
 /usr/include/bits/siginfo-consts.h \
 /usr/include/bits/siginfo-consts-arch.h \
 /usr/include/bits/types/sigval_t.h \
 /usr/include/bits/types/sigevent_t.h \
 /usr/include/bits/wordsize.h \
 /usr/include/bits/sigevent-consts.h \
 /usr/include/bits/sigaction.h \
 /usr/include/bits/sigcontext.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/bits/types/stack_t.h \
 ../tcc-bootstrap/include/stddef.h \
 /usr/include/sys/ucontext.h \
 /usr/include/bits/sigstack.h \
 /usr/include/bits/sigstksz.h \
 /usr/include/bits/ss_flags.h \
 /usr/include/bits/types/struct_sigstack.h \
 /usr/include/bits/sigthread.h \
 /usr/include/bits/signal_ext.h \
 x86_64-gen.c \
 /usr/include/assert.h \
 x86_64-link.c \
 i386-asm.c \
 x86_64-asm.h \
 x86_64-asm.h \
 tccasm.c \
 tcctools.c \
 /usr/lib/x86_64-linux-gnu/libc.so \
 /lib/x86_64-linux-gnu/libc.so.6 \
 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 \
 /usr/lib/x86_64-linux-gnu/libc_nonshared.a \
 /lib/x86_64-linux-gnu/libc.so.6 \
 /usr/lib/x86_64-linux-gnu/libc_nonshared.a \
 ../tcc-bootstrap/libtcc1.a \
 /usr/lib/x86_64-linux-gnu/crtn.o \

Here is what I did. I really just commented out one thing the config.h and added a few flags here. The rest of the changes are to make it slightly easier to compile. It fails with this error

The error.
cd tcc-0.9.27 && ./tcc0 -nostdinc -nostdlib -B ../tcc-boostrap -L../musl-bootstrap/lib -lc -I ../musl-bootstrap/include tcc.c -o tcc1
In file included from tcc.c:21:
In file included from tcc.h:293:
elf.h:43: error: ';' expected (got "Elf32_Half")
Error: Tried to longjmp from libtcc.c:548 with value 1
And the offending file.

if you revert those two lines then it works again but it links against the system libc files. I'm not very good with this stuff so I just wanted to ask if you tried something like this already or if I'm missing something obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions