[erlang-questions] [PATCH] Fix R15B02 cross-compilation for TileraMDE-3.0.1.125620

Motiejus Jakštys desired.mta@REDACTED
Thu Oct 11 19:15:23 CEST 2012


On Thu, Oct 11, 2012 at 12:10:39PM +0200, Björn-Egil Dahlberg wrote:
> On 2012-10-11 08:45, Motiejus Jakštys wrote:
> >On Wed, Oct 10, 2012 at 05:09:10PM +0200, Björn-Egil Dahlberg wrote:
> >>"'malloc_use_hash' only affects malloc (specifically, it affects the
> >>flags it passes to 'mmap' when it allocates more memory from Linux).
> >>You can also explicitly malloc memory with various caching attributes
> >>using custom mspaces.
> >>
> >I think it would make sense to conditionalize it during configuration
> >phase. But how to test for its existence/absence?
> How about doing this instead?
> 
> diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
> index 37dfcb1..176a5af 100644
> --- a/erts/emulator/sys/unix/sys.c
> +++ b/erts/emulator/sys/unix/sys.c
> @@ -408,8 +408,10 @@ void sys_tty_reset(int exit_code)
>  #ifdef __tile__
>  /* Direct malloc to spread memory around the caches of multiple tiles. */
>  #include <malloc.h>
> +#if defined(MALLOC_USE_HASH)
>  MALLOC_USE_HASH(1);
>  #endif
> +#endif
>  #ifdef USE_THREADS

Oh, it was a macro. Of course. :-)

> >>I guess it would be safe to remove "-OPT:Olimit=0
> >>-WOPT:lpre=off:spre=off:epre=off ".
> >>It is an optimization for tile-cc when compiling on target machine.
> >>An earlier comment in Makefile.in seems to have been removed, it said:
> >>
> >>+ifneq ($(filter tile-%,$(TARGET)),)
> >>+# Some tile-cc optimizations take pathologically long for beam_emu.c,
> >>+# so disable them.
> >>+$(OBJDIR)/beam_emu.o: beam/beam_emu.c
> >>+	$(CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) \
> >>+	  -OPT:Olimit=0 -WOPT:lpre=off:spre=off:epre=off \
> >>+	  $(INCLUDES) -c $< -o $@
> >>+endif
> >Can you verify that it compiles in "reasonable time" on your system with
> >these flags turned off?
> Also, tag - you’re it!

Did not understand the above sentence.

> It would be greatly appreciated if you could summarize problems and
> solution you have found for building and using Erlang on the Tilera
> card or if you find something we can change to make anyones
> experience just a bit easier. I don't know exactly where we should
> put this documentation but my suggestion would either be in the
> documentation for cross compiling or as a specific page on the
> GitHub Wiki. If the information arrives, we will surely find a place
> to put it. =)

When one is doing
./otp_build autoconf[*]
./otp_build configure --xcomp-conf=FILE
make

Then everything in documentation makes sense and is really clear.

However, if one wants to cross-compile using ./configure[⚗], then you have
to know the cpu-vendor-os triplet. I got it while invoking GCC on the
target machine:

    $ tile-monitor --resume --pci --resume --root -- gcc -v
    Using built-in specs.
    Target: tile-unknown-linux-gnu
    ...
    
Is there a better way? Anyway, this or the better way, I think, could be
documented.

If people run into compilation problems, usually it is not Erlang
specific. It's a missing macro, invalid compiler flag, missing function
during linking.. Standard stuff which is common to any C project. I am
afraid it does not make sense to add help to the Erlang building
documentation. Like "try removing stuff that is complaining and see
what happens" (the way I did) is too easy to be misinterpreted, and
whilst if you provide more aid you just repeat general C knowledge.

Sadly, specific questions are asked, without a reply[1].


Anyway, regarding code. Should I "prepare" a new patch with an updated
commit message, or what you have is good enough to be merged?

Regards,
Motiejus

[*]: I am building from git source.
[⚗]: I used ./otp_build only, and this is speculation. Not sure if would work.
[1]: http://erlang.org/pipermail/erlang-questions/2011-October/061727.html



More information about the erlang-questions mailing list