1

(I have the answer to this already; I'm going to answer my own question so that I can share what I've learned and save someone else this trouble in the future)

When I attempt to build Erlang on Solaris 10 Sparcv9, the build fails partway through:

cd lib && \
  ERL_TOP=/var/tmp/pkgbuild-0/erlang/sparcv9/erlang-otp-73b4221 PATH=/var/tmp/pkgbuild-0/erlang/sparcv9/erlang-otp-73b4221/bootstrap/bin:${PATH} \
        make opt SECONDARY_BOOTSTRAP=true
make[1]: Entering directory `/var/tmp/pkgbuild-0/erlang/sparcv9/erlang-otp-73b4221/lib'
make[2]: Entering directory `/var/tmp/pkgbuild-0/erlang/sparcv9/erlang-otp-73b4221/lib/hipe'
=== Entering application hipe
make[3]: Entering directory `/var/tmp/pkgbuild-0/erlang/sparcv9/erlang-otp-73b4221/lib/hipe/misc'
erlc -W  +debug_info +warn_exported_vars +warn_missing_spec +warn_untyped_record -o../ebin hipe_consttab.erl
make[3]: *** [../ebin/hipe_consttab.beam] Bus Error (core dumped)
make[3]: Leaving directory `/var/tmp/pkgbuild-0/erlang/sparcv9/erlang-otp-73b4221/lib/hipe/misc'

Why is this and what can I do to complete my Erlang build?

Wez Furlong
  • 4,727
  • 1
  • 29
  • 34

1 Answers1

5

The reason that the build fails is due to a broken build environment.

In this specific case the Sun GCC build is being used. This particular version of GCC was compiled to use a mixture of the the GNU assembler and the Sun linker.

The Sparc platform is highly sensitive to alignment of code and it will fault (for example, with a bus error) if unaligned code is executed.

The GNU assembler used by the stock GCC build on Sparc Solaris 10 doesn't work so hard to automatically align functions generated by the compiler, leading to unaligned code.

The solution is to build your own GCC and make sure that you use the system assembler and linker; you can achieve this by using the following options to GCC's configure script:

  --with-as=/usr/ccs/bin/as \
  --without-gnu-as \
  --without-gnu-ld \
  --with-ld=/usr/ccs/bin/ld \

The resultant GCC build will generated properly aligned code and allow you to build Erlang successfully.

Wez Furlong
  • 4,727
  • 1
  • 29
  • 34