Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling with tcc (TinyC Compiler) #132

Open
prologic opened this issue Apr 10, 2020 · 9 comments
Open

Compiling with tcc (TinyC Compiler) #132

prologic opened this issue Apr 10, 2020 · 9 comments

Comments

@prologic
Copy link

When I try to compile with tcc it ends with this error:

echo '} struct_printers;' >> printers.h-t
echo 'extern const struct_printers *printers;' >> printers.h-t
echo '#define MPERS_PRINTER_NAME(printer_name) printers->printer_name' >> printers.h-t
mv printers.h-t printers.h
for f in linux/32/syscallent.h linux/64/syscallent.h linux/aarch64/syscallent.h linux/aarch64/syscallent1.h linux/alpha/syscallent.h linux/arc/syscallent.h linux/arm/syscallent.h linux/avr32/syscallent.h linux/bfin/syscallent.h linux/csky/syscallent.h linux/hppa/syscallent.h linux/i386/syscallent.h linux/ia64/syscallent.h linux/m68k/syscallent.h linux/metag/syscallent.h linux/microblaze/syscallent.h linux/mips/syscallent-n32.h linux/mips/syscallent-n64.h linux/mips/syscallent-o32.h linux/mips/syscallent.h linux/nios2/syscallent.h linux/or1k/syscallent.h linux/powerpc/syscallent.h linux/powerpc64/syscallent.h linux/powerpc64/syscallent1.h linux/powerpc64le/syscallent.h linux/riscv64/syscallent.h linux/s390/syscallent.h linux/s390x/syscallent.h linux/s390x/syscallent1.h linux/sh/syscallent.h linux/sh64/syscallent.h linux/sparc/syscallent.h linux/sparc64/syscallent.h linux/sparc64/syscallent1.h linux/subcall.h linux/syscallent-common-32.h linux/syscallent-common.h linux/tile/syscallent.h linux/tile/syscallent1.h linux/x32/syscallent.h linux/x32/syscallent1.h linux/x86_64/syscallent.h linux/x86_64/syscallent1.h linux/xtensa/syscallent.h; do cat -- $f; done | \
	D="" \
	./generate_sen.sh > sen.h
for f in access.c affinity.c aio.c alpha.c basic_filters.c bind.c bjm.c block.c bpf.c bpf_filter.c bpf_seccomp_filter.c bpf_sock_filter.c btrfs.c cacheflush.c capability.c chdir.c chmod.c clone.c copy_file_range.c count.c delay.c desc.c dirent.c dirent64.c dm.c dyxlat.c epoll.c error_prints.c evdev.c evdev_mpers.c eventfd.c execve.c fadvise.c fallocate.c fanotify.c fchownat.c fcntl.c fetch_bpf_fprog.c fetch_struct_flock.c fetch_struct_keyctl_kdf_params.c fetch_struct_mmsghdr.c fetch_struct_msghdr.c fetch_struct_stat.c fetch_struct_stat64.c fetch_struct_statfs.c fetch_struct_xfs_quotastat.c file_handle.c file_ioctl.c filter_qualify.c filter_seccomp.c flock.c fs_x_ioctl.c fsconfig.c fsmount.c fsopen.c fspick.c futex.c get_personality.c get_robust_list.c getcpu.c getcwd.c getrandom.c hdio.c hostname.c inotify.c inotify_ioctl.c io.c io_uring.c ioctl.c ioperm.c iopl.c ioprio.c ipc_msg.c ipc_msgctl.c ipc_sem.c ipc_shm.c ipc_shmctl.c kcmp.c kexec.c keyctl.c kvm.c ldt.c link.c listen.c lookup_dcookie.c loop.c lseek.c mem.c membarrier.c memfd_create.c mknod.c mmap_notify.c mmsghdr.c mount.c move_mount.c mq.c msghdr.c mtd.c nbd_ioctl.c net.c netlink.c netlink_crypto.c netlink_inet_diag.c netlink_kobject_uevent.c netlink_netfilter.c netlink_netlink_diag.c netlink_packet_diag.c netlink_route.c netlink_selinux.c netlink_smc_diag.c netlink_sock_diag.c netlink_unix_diag.c nlattr.c nsfs.c numa.c number_set.c oldstat.c open.c open_tree.c or1k_atomic.c pathtrace.c perf.c perf_ioctl.c personality.c pidfd_open.c pkeys.c poll.c prctl.c print_aio_sigset.c print_dev_t.c print_group_req.c print_ifindex.c print_instruction_pointer.c print_kernel_version.c print_mac.c print_mq_attr.c print_msgbuf.c print_sg_req_info.c print_sigevent.c print_statfs.c print_struct_stat.c print_time.c print_timespec.c print_timespec32.c print_timespec64.c print_timeval.c print_timeval64.c print_timex.c printmode.c printrusage.c printsiginfo.c process.c process_vm.c ptp.c ptrace_syscall_info.c quota.c random_ioctl.c readahead.c readlink.c reboot.c renameat.c resource.c retval.c riscv.c rt_sigframe.c rt_sigreturn.c rtc.c rtnl_addr.c rtnl_addrlabel.c rtnl_dcb.c rtnl_link.c rtnl_mdb.c rtnl_neigh.c rtnl_neightbl.c rtnl_netconf.c rtnl_nsid.c rtnl_route.c rtnl_rule.c rtnl_tc.c rtnl_tc_action.c s390.c sched.c scsi.c seccomp.c sendfile.c sg_io_v3.c sg_io_v4.c shutdown.c sigaltstack.c signal.c signalfd.c sock.c sockaddr.c socketutils.c sparc.c sram_alloc.c stage_output.c stat.c stat64.c statfs.c statx.c strace.c string_to_uint.c swapon.c syscall.c sysctl.c sysinfo.c syslog.c sysmips.c term.c time.c times.c truncate.c ubi.c ucopy.c uid.c uid16.c umask.c umount.c uname.c userfaultfd.c ustat.c util.c utime.c utimes.c v4l2.c wait.c watchdog_ioctl.c xattr.c xlat.c xmalloc.c fetch_indirect_syscall_args.c fstatfs.c fstatfs64.c getpagesize.c ipc.c mmap_cache.c sigreturn.c socketcall.c statfs64.c sync_file_range.c sync_file_range2.c upeek.c upoke.c; do \
	sed -n 's/^SYS_FUNC(.*/extern &;/p' $f; \
done | sort -u > sys_func.h
tcc -E -P -DHAVE_CONFIG_H    -I./linux/x86_64 -I./linux/x86_64 -I./linux -I./linux -I. -I.  -include config.h linux/x86_64/syscallent.h -o syscallent.i
tcc: erro
make: *** [Makefile:9840: syscallent.i] Error 1
rm ioctlsort0 ioctlsort1.o ioctlsort2 ioctlsort0.o ioctls_all0.h ioctlsort2.o ioctls_all2.h ioctls_all1.h ioctlsort1
#

It's not clear to me what specifiaclly is an 'unrecognized file type"

Is strace known to compile successfully with tcc?

@prologic
Copy link
Author

This is the build script:

name=strace
version=5.4
release=1
source="https://github.com/strace/strace/releases/download/v$version/$name-$version.tar.xz"

build() {
  cd $name-$version
  ./configure \
    --prefix=/usr \
    --enable-mpers=no
  make
  make DESTDIR="$PKG" install
}

@ldv-alt
Copy link
Member

ldv-alt commented Apr 10, 2020 via email

@prologic
Copy link
Author

Sorry, the error message tcc: erro is too cryptic.

I think this was a bad copy/paste :/ -- Actually the ./configure script doesn't even handle setting the CC env var very well :/

checking for gcc... tcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... no
checking whether tcc accepts -g... yes
checking for tcc option to accept ISO C89... none needed
checking whether tcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of tcc... tcc
checking for tcc option to accept ISO C99... none needed
checking for tcc option to accept ISO Standard C... (cached) none needed
checking how to run the C preprocessor... tcc -E
checking whether tcc handles -Werror -Wunknown-warning-option... yes
checking whether tcc handles -Wall... yes
checking whether tcc handles -Wempty-body... yes
checking whether tcc handles -Wformat-security... yes
checking whether tcc handles -Wignored-qualifiers... yes
checking whether tcc handles -Wimplicit-fallthrough=5... yes
checking whether tcc handles -Winit-self... yes
checking whether tcc handles -Winitializer-overrides... yes
checking whether tcc handles -Wlogical-op... yes
checking whether tcc handles -Wmissing-parameter-type... yes
checking whether tcc handles -Wnested-externs... yes
checking whether tcc handles -Wold-style-declaration... yes
checking whether tcc handles -Wold-style-definition... yes
checking whether tcc handles -Woverride-init... yes
checking whether tcc handles -Wsign-compare... yes
checking whether tcc handles -Wtype-limits... yes
checking whether tcc handles -Wwrite-strings... yes
configure: looking for a C compiler that generates native executables
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/strace/build/src/strace-5.4':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
#

This is a bit strange; most other software respects the CC env var.

This is the Pkgfile:

#!/bin/sh
# shellcheck disable=SC2034

# Description: ...
# URL:         ...
# Maintainer:  ...

name=strace
version=5.4
release=1
source="https://github.com/strace/strace/releases/download/v$version/$name-$version.tar.xz"

build() {
  cd $name-$version

  ./configure \
    --prefix=/usr \
    --enable-mpers=no

  make -j "$(nproc)"

  make DESTDIR="$PKG" install
}

@esyr
Copy link
Member

esyr commented Apr 20, 2020 via email

@prologic
Copy link
Author

CC_FOR_BUILD has to be supplied with a path to a C compiler that

is that a standard env var for this type of thing?

@prologic
Copy link
Author

Okay I added this to the. build and now I get the original error I was trying to show here before:

mv native_printer_defs.h-t native_printer_defs.h
tcc -E -P -DHAVE_CONFIG_H    -I./linux/x86_64 -I./linux/x86_64 -I./linux -I./linux -I. -I.  -include config.h linux/x86_64/syscallent.h -o syscallent.i
tcc: error: unrecognized file type
make: *** [Makefile:9840: syscallent.i] Error 1
make: *** Waiting for unfinished jobs....
echo '} struct_printers;' >> printers.h-t
echo 'extern const struct_printers *printers;' >> printers.h-t
echo '#define MPERS_PRINTER_NAME(printer_name) printers->printer_name' >> printers.h-t
mv printers.h-t printers.h
rm ioctls_all0.h ioctls_all2.h ioctls_all1.h
#

@esyr
Copy link
Member

esyr commented Apr 20, 2020 via email

@prologic
Copy link
Author

Thanks! I'll look into this further! Thanks for the clarification.

@esyr
Copy link
Member

esyr commented Apr 20, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants