void-linux / void-packages

The Void source packages collection
https://voidlinux.org
Other
2.6k stars 2.16k forks source link

Tcc won't link executables #30630

Open niansa opened 3 years ago

niansa commented 3 years ago

System

Expected behavior

Executable file should be generated by tcc

Actual behavior

tcc: error: file 'crtn.o' not found

Steps to reproduce the behavior

echo "int main(){}" | tcc -
loreb commented 3 years ago

Confirmed; it works fine (musl&glibc) after installing gcc (probably also clang), but their templates are complicated enough that imho the easiest solution would be to depend on one or the other, even if it pulls in some unnecessary dependencies.

If you feel like doing some boring work:

Of course. if you wish not to lose your sanity, do the first step by hand, and then write a script to do the rest!!!

ericonr commented 3 years ago

Could try glibc-devel or musl-devel.

loreb commented 3 years ago

Using a fresh install, this is what I got...

But that's a separate bug.

hiltjo commented 3 years ago

Hi, this is still broken and has been broken for quite a while now on VoidLinux glibc.

loreb commented 3 years ago

@hiltjo @niansa

It stayed broken because 99.9% of the people who install tcc also install gcc/clang, which happen to pull in the required dependency :)

Copy/paste the fix from gcc's template:

case "$XBPS_TARGET_MACHINE" in
        *-musl)  depends+=" musl-devel";;
        *)       depends+=" glibc-devel";;
esac

and submit a pull request (unless it's troublesome for some reason)

hiltjo commented 3 years ago

Hi,

Have you tested that fix on Void Linux glibc?

I've had gcc, clang and glibc-devel installed, so that's not the issue I think.

But even if it would be the solution then maybe it should be documented somewhere this file is required. Some distributions show such information when the package is installed (just an idea).

loreb commented 3 years ago

@hiltjo I tried it above in https://github.com/void-linux/void-packages/issues/30630#issuecomment-834266375 except that I tried it by installing musl/glibc void in qemu and installing musl-devel/glibc-devel by hand instead of fixing the template, but I expect that it should work.

loreb commented 3 years ago

@hiltjo wait, I believe we have a miscommunication...

My assumptions:

  1. the bugfix is simple, so ericonr is leaving it for grabs (as a first PR or something like that)
  2. you or niansa care enough to submit a PR

The template is the file used by the package manager to get the info it needs about the package, in this case its dependencies; adding the dependencies above in an empty install makes tcc work, and those lines are copy/pasted from gcc's dependencies, so adding them to the template (srcpkgs/tcc/template) should fix the bug.

If you or @niansa want to submit a PR, it's pretty much written for you; otherwise @ericonr can you add a "good first issue" label?

hiltjo commented 2 years ago

This is still broken on the glibc version. I have glibc-devel, clang and gcc installed...

loreb commented 2 years ago

@hiltjo Just to be sure we are seeing the same thing: on a glibc vm I see the crt1.o error and it works anyway, ie tcc helloworld.c && ./a.out prints "hello world", is it the same for you?

hiltjo commented 2 years ago

Yeah, the binary seems to work.

The displayed errors are still: /usr/lib/crt1.o: error: Invalid relocation entry [14] '.rela.debug_info' @ 000004f6 tcc: error: file 'crt1.o' not found

loreb commented 2 years ago

@hiltjo The problem is that upstream hasn't made a release in the past years and the package is orphaned... meaning that I have no idea if the upstream is conservative ("every commit could be a release!") or more let's say experimental ("there's a good reason we haven't made a release..."); the latest commit doesn't have this problem (just tested in a vm), so go on, git bisect and submit a pr to fix the crt1.o issue as well.

Before you ask: the package works well enough for me as is, I only use tcc for scripts ("#! /usr/bin/tcc -run"), and that works fine even on void/glibc.

ericonr commented 2 years ago

I don't think releases are planned anymore, the development model is a public git branch that basically anyone can send stuff into.