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

Björn-Egil Dahlberg <>
Wed Oct 10 17:09:10 CEST 2012


On 2012-10-10 16:08, Motiejus Jaks(tys wrote:
> Applying the patch below let me cross-compile and run R15B02 on Tilera64
> using TileraMDE-3.0.1.125620.
>
> In order to prepare a clean patch, I have to know what do the options
> -OPT:Olimit=0 -WOPT:lpre=off:spre=off:epre=off do on the machines that
> support it? Also, what is the meaning of -MALLOC_USE_HASH(1)?

I am quoting from Tilera here:

"'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.

The 'hash_default' argument in the .hvconfig file affects 'mmap' calls
that do not specify homing information.  Because malloc*does*  specify
homing information, at least when you are pthreaded, 'hash_default' is
ignored and malloc_use_hash is required to get hash-for-home."


This was something included in TileraMDE 2.0 beta (perhaps removed since 
then).
I found it in TileraMDE-2.1.2/tile64/tile/usr/include/malloc.h though.

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

Patch was supplied by Tilera Corp.

Regards,
Björn-Egil Dahlberg
Erlang/OTP


>
> Overall, thumbs up to the OTP team for making cross compilation very easy.
> :)
>
> ---
>
> -OPT:Olimit=0 -WOPT:lpre=off:spre=off:epre=off
> tile-gcc 4.4.3 does accept these options:
>
> cc1: error: unrecognized command line option
> "-WOPT:lpre=off:spre=off:epre=off"
>
> MALLOC_USE_HASH is not defined anywhere in the mentioned build
> environment.
> ---
>   erts/emulator/Makefile.in    |    1 -
>   erts/emulator/sys/unix/sys.c |    6 ------
>   2 files changed, 7 deletions(-)
>
> diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in
> index 985ef72..644ca18 100644
> --- a/erts/emulator/Makefile.in
> +++ b/erts/emulator/Makefile.in
> @@ -633,7 +633,6 @@ endif
>   ifneq ($(filter tile-%,$(TARGET)),)
>   $(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 $@
>   else
>   # Usually the same as the default rule, but certain platforms (e.g. win32) mix
> diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
> index c1fa00b..4c168b6 100644
> --- a/erts/emulator/sys/unix/sys.c
> +++ b/erts/emulator/sys/unix/sys.c
> @@ -398,12 +398,6 @@ void sys_tty_reset(int exit_code)
>     }
>   }
>   
> -#ifdef __tile__
> -/* Direct malloc to spread memory around the caches of multiple tiles. */
> -#include <malloc.h>
> -MALLOC_USE_HASH(1);
> -#endif
> -
>   #ifdef USE_THREADS
>   
>   #ifdef ERTS_THR_HAVE_SIG_FUNCS

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121010/97e8ce76/attachment.html>


More information about the erlang-questions mailing list