www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Build/install errors on Linux with LinuxBrew/HomeBrew

Hello,

Not sure if this is the right place (if not, please point me to the right
person/mailing list).
My issue deals with installing the latest dmd (2.065.0) on Linux 64bit through
LinuxBrew/HomeBrew system (so, not easy to tell who to contact).

The simple fixes are here:
   https://github.com/agordon/homebrew/compare/dmd_linuxbrew

But I thought to get an opinion from the relevant D people before sending a
Pull-Request to HomeBrew.
To the best of my understanding, these minor changes should not cause any
problems for MacOS-X homebrew installation, but they will enable LinuxBrew
installations.

Thanks,
  -gordon


The installation fails ("brew install dmd"), and it is caused by three separate
issues:

1. For phobos 2.065.0, on linux 64bit,
running:
   make install -f posix.max
instead of
   make -f posix.max && make install -f posix.max

doesn't properly create the share objects (only the static ".a" library).
(see log below).
While this is probably a problem with Phobo's posix.mak, version 2.065.0 is
already released and can't be changed.
I assume this is not a problem for MacOS build, so "homebrew" doesn't fail. But
"linuxbrew" does fail.

I suggest a small addition to the 'dmd.rb' formula, to first run "make" without
install.


2. The HomeBrew 'dmd.rb' formula contains the following code to set the dmd
config:
===
     inreplace bin/'dmd.conf', "DFLAGS=-I% P%/../../src/phobos
-I% P%/../../src/druntime/import -L-L% P%/../lib",

===
It replaces the default values from "./ini/XXX/bin/dmd.conf" to the ones
suitable for homebrew.

But there's a catch:
For MacOS-X, the default config has only one line which ends with "lib", and
the replacement works.
For Linux, the default config has two lines, one ends with "lib32" and the
other ends with "lib64".
So the replacement above is partial, and ends up with an invalid "dmd.conf".

final conf file will have ".../linuxbrew/Cellar/dmd/2.065.0/lib32" and
".../linuxbrew/Cellar/dmd/2.065.0/lib64" - both don't exist and the
configuration is invalid.

I suggest a small change, instead of replacing a fixed string, replace a regex
for the DLANG line.


3. The 'dmd.rb' formula copies the configuration file to the Homebrew's "etc"
directory - but not if there's already a file there.
So, if the existing HomeBrew "dmd.conf" exists and contains invalid data (e.g
to a previous homebrew version, or a bad install),
it is not updated by the new install.
This is perhaps a "homebrew" issue, but it affects the dmd formula which I'm
trying to fix.

This can be replicated by:
     $ brew uninstall dmd
     $ echo "Foo Bar" > $HOMEBREWDIR/etc/dmd.conf
     $ brew install dmd

invalid.

A small fix to the formula deletes an old dmd.conf if it exists.





==== Example of Phobos on Linux64 not creating the shared object ====
$ cd src/phobos/
$ rm generated/linux/release/64/lib*
$ make -f posix.mak install
make --no-print-directory OS=linux -f posix.mak MODEL=64 BUILD=release
INSTALL_DIR=../install \
		DMD=../dmd/src/dmd install2
make -C ../druntime -f posix.mak MODEL=64 DMD=../dmd/src/dmd OS=linux
make[2]: Nothing to be done for `target'.
../dmd/src/dmd -I../druntime/import  -w -d -m64  -O -release -lib
-ofgenerated/linux/release/64/libphobos2.a
../druntime/lib/libdruntime-linux64.a std/algorithm.d std/array.d std/ascii.d
std/base64.d std/bigint.d std/bitmanip.d std/compiler.d std/complex.d
std/concurrency.d std/container.d std/conv.d std/cstream.d std/csv.d
std/datetime.d std/demangle.d std/encoding.d std/exception.d std/file.d
std/format.d std/functional.d std/getopt.d std/json.d std/math.d
std/mathspecial.d std/metastrings.d std/mmfile.d std/numeric.d std/outbuffer.d
std/parallelism.d std/path.d std/process.d std/random.d std/range.d std/regex.d
std/signals.d std/socket.d std/socketstream.d std/stdint.d std/stdio.d
std/stdiobase.d std/stream.d std/string.d std/syserror.d std/system.d
std/traits.d std/typecons.d std/typetuple.d std/uni.d std/uri.d std/utf.d
std/uuid.d std/variant.d std/xml.d std/zip.d std/zlib.d std/c/linux/linux.d
std/c/linux/socket.d etc/c/curl.d etc/c/sqlite3.d etc/c/zlib.d std/c/fenv.d s
 td/c/loca
le.d std/c/math.d std/c/process.d std/c/stdarg.d std/c/stddef.d std/c/stdio.d
std/c/stdlib.d std/c/string.d std/c/time.d std/c/wcharh.d
std/internal/digest/sha_SSSE3.d std/internal/math/biguintcore.d
std/internal/math/biguintnoasm.d std/internal/math/biguintx86.d
std/internal/math/gammafunction.d std/internal/math/errorfunction.d
std/internal/processinit.d std/internal/uni.d std/internal/uni_tab.d
std/internal/unicode_tables.d std/internal/unicode_comp.d
std/internal/unicode_decomp.d std/internal/unicode_grapheme.d
std/internal/unicode_norm.d std/net/isemail.d std/net/curl.d
std/digest/digest.d std/digest/crc.d std/digest/md.d std/digest/ripemd.d
std/digest/sha.d generated/linux/release/64/etc/c/zlib/adler32.o
generated/linux/release/64/etc/c/zlib/compress.o
generated/linux/release/64/etc/c/zlib/crc32.o
generated/linux/release/64/etc/c/zlib/deflate.o
generated/linux/release/64/etc/c/zlib/gzclose.o
generated/linux/release/64/etc/c/zlib/gzlib.o generated/linux/release/64/etc/c/
 zlib/gzre
ad.o generated/linux/release/64/etc/c/zlib/gzwrite.o
generated/linux/release/64/etc/c/zlib/infback.o
generated/linux/release/64/etc/c/zlib/inffast.o
generated/linux/release/64/etc/c/zlib/inflate.o
generated/linux/release/64/etc/c/zlib/inftrees.o
generated/linux/release/64/etc/c/zlib/trees.o
generated/linux/release/64/etc/c/zlib/uncompr.o
generated/linux/release/64/etc/c/zlib/zutil.o
mkdir -p ../install/lib
cp generated/linux/release/64/libphobos2.a ../install/lib/
cp -P generated/linux/release/64/libphobos2.so.0.65.0
generated/linux/release/64/libphobos2.so.0.65
generated/linux/release/64/libphobos2.so ../install/lib/
cp: cannot stat ‘generated/linux/release/64/libphobos2.so.0.65.0’: No such file
or directory
cp: cannot stat ‘generated/linux/release/64/libphobos2.so.0.65’: No such file
or directory
cp: cannot stat ‘generated/linux/release/64/libphobos2.so’: No such file or
directory
make[1]: *** [install2] Error 1
make: *** [install] Error 2
=======
Mar 11 2014