tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Ported tcc to Solaris/Illumos x86


From: grischka
Subject: Re: [Tinycc-devel] Ported tcc to Solaris/Illumos x86
Date: Fri, 14 Jul 2023 12:03:53 +0200
User-agent: Mozilla/5.0 (Windows NT 6.0; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 11.07.2023 07:22, Brian Callahan wrote:
Hi all --

Attached for review/testing is a diff that enables TCC to work on
Solaris/Illumos x86. Tested on an OpenIndiana (Illumos distro) machine,
where all tests pass when running TCC as an i386 compiler.
Solaris/Illumos is a multiarch environment. Modern Illumos is a 64-bit
kernel only, but 32-bit binaries work just fine; the Illumos people care
a lot about backwards compatibility.

Hi,

that sounds good.  For the people who might want to try this but do
not necessarily have the same insight as you do have by now, I'd suggest
to at least try to tackle the remaining issues in the sense of an out
of the box experience:

* configure:  maybe it is possible to let configure detect this
 "not smart enough" shell and if so print some informative message
  (such as "Better use bash configure on this system") or maybe even
  re-execute itself using bash then.

* path to diff etc. tools:  it might be possible to set the "Path"
  variable in the (top section of the top level-) Makefile, conditionally

* gcc build cross tcc on i386:  Maybe it's still possible one way or
  the other to detect that we're compiling for i386 even under gcc.
  The logic in tcc.h is

      # if defined __i386__ && defined TCC_TARGET_I386
      #  define TCC_IS_NATIVE

  For example MSVC defines just _x86_, which is why there is

      #  ifdef _X86_
      #   define __i386__ 1
      #  endif

* __start_crt_compiler: referenced symbol not found
  Seems you'd need to provide this function, for example in libtcc1.a.
  Google has some info about it.

* relocation R_AMD64_COPY offset invalid: _DYNAMIC: offset=0xa00a08 lies
  outside memory image;

  Don't know.  COPY relocs normally are generated only by the tcc linker
  itself for bss symbols.  Is "_DYNAMIC" the symbol name?  Does it have
  a "symbol size" (esym->st_size) ?  Try objdump -R,  See also tccelf.c:1941

-- gr

Illumos is interesting because it is a variant of early Solaris 11, with
about a decade of divergence from Oracle. The way I set up support is to
declare Illumos effectively a sub TARGETOS of Solaris.

To build and test, you will want to ensure that the GNU tools are found
first in your PATH. This is because TCC assumes GNU install and GNU
diff, but on Illumos Sun install and Sun diff are found first with the
default PATH. You can fix this by running `export
PATH=/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin` before building TCC. You'll
also need to run the configure script with `bash configure` as /bin/sh
on Illumos is not smart enough to run the configure script.

As mentioned, all tests pass on Illumos i386. In order to run the tests,
you need to rebuild TCC with itself. This is because GCC on Illumos
unconditionally declares itself to be amd64, even when in i386 mode. As
such, TCC built with GCC fails the tests because TCC thinks it's a cross
compiler and the -run test errors out because of this. Once you rebuild
TCC with itself, it'll correctly think it's a native compiler and run
all the tests.

I believe all the bits for amd64 support are there and good to go.
However, there is a linker issue that prevents binaries from working
correctly. The message you receive is:
ld.so.1: <exe name>: fatal: relocation error: file <exe name>: symbol
__start_crt_compiler: referenced symbol not found

However, you get what I think is the real problem if you run `ldd -d` on
the binary:
relocation R_AMD64_COPY offset invalid: _DYNAMIC: offset=0xa00a08 lies
outside memory image; relocation discarded

If you can help fix this, that would be great. With that said, the i386
version of TCC ought to be enough for the vast majority of use cases for
TCC on Solaris/Illumos, so I am sharing the diff now.

Is it worth waiting around for testing or should I just go ahead and
push this to mob?

Thanks.

~Brian



_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]