llvm-gcc build of inferno/plan 9 'mk' fails

hello,

I'm attempting to build the inferno source tree using either of native
LTO or jit'd bins and having no obvious luck.

im using macports (current as of this email) llvm-2.5 and llvm-gcc on
a macbook pro (x86)

following the inferno directions verbatim will use 'cc' as the
compiler and just works.
the build tools are different from the naive build tools as follows:

CC="p llvm-gcc-4.2 `llvm-config --cflags` -march=i386 --emit-llvm -O0
  -c -I$PLAT/include -I$ROOT/include -I$ROOT/utils/ include"
LD="p llvm-ld `llvm-config --ldflags --libs all `"
AR="p llvm-ar crvs"

any simplifications or rules of thumb that might help would be greatly
appreciated....

the build proceeds, finishes, and leaves me guessing:

#957$457 Thu 09073022:29:22 jim@bframe4:~/work/inferno
: CC=llvm-gcc-4.2
PATH=/usr/local/inferno/MacOSX/386/bin/:/opt/local/bin:$PATH
./makemk.sh
removing old libraries and binaries
llvm-gcc-4.2 -I/opt/local/include -D_DEBUG -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -march=i386
--emit-llvm -O0 -c -I/usr/local/inferno/MacOSX/386/include
-I/usr/local/inferno/include -I/usr/local/inferno/utils/include
regaux.c regcomp.c regerror.c regexec.c regsub.c rregexec.c rregsub.c
llvm-ar crvs /usr/local/inferno/MacOSX/386/lib/libregexp.a regaux.o
regcomp.o regerror.o regexec.o regsub.o rregexec.o rregsub.o
llvm-ranlib /usr/local/inferno/MacOSX/386/lib/libregexp.a
llvm-gcc-4.2 -I/opt/local/include -D_DEBUG -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -march=i386
--emit-llvm -O0 -c -I/usr/local/inferno/MacOSX/386/include
-I/usr/local/inferno/include -I/usr/local/inferno/utils/include
bbuffered.c bfildes.c bflush.c bgetc.c bgetd.c bgetrune.c binit.c
boffset.c bprint.c bputc.c bputrune.c brdline.c bread.c bseek.c
bwrite.c
llvm-ar crvs /usr/local/inferno/MacOSX/386/lib/libbio.a bbuffered.o
bfildes.o bflush.o bgetc.o bgetd.o bgetrune.o binit.o boffset.o
bprint.o bputc.o bputrune.o brdline.o bread.o bseek.o bwrite.o
llvm-ranlib /usr/local/inferno/MacOSX/386/lib/libbio.a
llvm-gcc-4.2 -I/opt/local/include -D_DEBUG -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -march=i386
--emit-llvm -O0 -c -I/usr/local/inferno/MacOSX/386/include
-I/usr/local/inferno/include -I/usr/local/inferno/utils/include
dirstat-posix.c rerrstr.c errstr-posix.c getuser-posix.c charstod.c
cleanname.c create.c dirwstat.c fmtprint.c fmtvprint.c fprint.c
print.c runeseprint.c runesmprint.c runesnprint.c runevseprint.c
seprint.c smprint.c snprint.c sprint.c vfprint.c vseprint.c vsmprint.c
vsnprint.c dofmt.c dorfmt.c errfmt.c fcallfmt.c fltfmt.c fmt.c fmtfd.c
fmtlock.c fmtprint.c fmtquote.c fmtrune.c fmtstr.c fmtvprint.c exits.c
getfields.c pow10.c print.c qsort.c rune.c runestrlen.c seek.c
strdup.c strtoll.c utflen.c utfrrune.c utfrune.c utfecpy.c utflen.c
utfnlen.c utfrrune.c utfrune.c strecpy.c
llvm-ar crvs /usr/local/inferno/MacOSX/386/lib/lib9.a dirstat-posix.o
rerrstr.o errstr-posix.o getuser-posix.o charstod.o cleanname.o
create.o dirwstat.o fmtprint.o fmtvprint.o fprint.o print.o
runeseprint.o runesmprint.o runesnprint.o runevseprint.o seprint.o
smprint.o snprint.o sprint.o vfprint.o vseprint.o vsmprint.o
vsnprint.o dofmt.o dorfmt.o errfmt.o fcallfmt.o fltfmt.o fmt.o fmtfd.o
fmtlock.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o exits.o
getfields.o pow10.o print.o qsort.o rune.o runestrlen.o seek.o
strdup.o strtoll.o utflen.o utfrrune.o utfrune.o utfecpy.o utflen.o
utfnlen.o utfrrune.o utfrune.o strecpy.o
llvm-ranlib /usr/local/inferno/MacOSX/386/lib/lib9.a
llvm-gcc-4.2 -I/opt/local/include -D_DEBUG -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -march=i386
--emit-llvm -O0 -c -I/usr/local/inferno/MacOSX/386/include
-I/usr/local/inferno/include -I/usr/local/inferno/utils/include
Posix.c sh.c arc.c archive.c bufblock.c env.c file.c graph.c job.c
lex.c main.c match.c mk.c parse.c recipe.c rule.c run.c shprint.c
symtab.c var.c varsub.c word.c
llvm-ld -L/opt/local/lib -lpthread -lm /opt/local/lib/LLVMXCore.o
/opt/local/lib/LLVMSparcCodeGen.o /opt/local/lib/LLVMSparcAsmPrinter.o
/opt/local/lib/LLVMPowerPCAsmPrinter.o
/opt/local/lib/LLVMPowerPCCodeGen.o /opt/local/lib/LLVMPIC16.o
/opt/local/lib/LLVMMSIL.o /opt/local/lib/LLVMMips.o -lLLVMLinker
-lLLVMipo /opt/local/lib/LLVMInterpreter.o -lLLVMInstrumentation
/opt/local/lib/LLVMIA64.o /opt/local/lib/LLVMExecutionEngine.o
/opt/local/lib/LLVMJIT.o -lLLVMDebugger
/opt/local/lib/LLVMCppBackend.o /opt/local/lib/LLVMCellSPUCodeGen.o
/opt/local/lib/LLVMCellSPUAsmPrinter.o /opt/local/lib/LLVMCBackend.o
-lLLVMBitWriter /opt/local/lib/LLVMX86AsmPrinter.o
/opt/local/lib/LLVMX86CodeGen.o -lLLVMAsmParser
/opt/local/lib/LLVMARMAsmPrinter.o /opt/local/lib/LLVMARMCodeGen.o
-lLLVMArchive -lLLVMBitReader /opt/local/lib/LLVMAlphaCodeGen.o
-lLLVMSelectionDAG /opt/local/lib/LLVMAlphaAsmPrinter.o
-lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMTransformUtils
-lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMSupport
-lLLVMSystem -o mk Posix.o sh.o arc.o archive.o bufblock.o env.o
file.o graph.o job.o lex.o main.o match.o mk.o parse.o recipe.o rule.o
run.o shprint.o symtab.o var.o varsub.o word.o
/usr/local/inferno/MacOSX/386/lib/libregexp.a
/usr/local/inferno/MacOSX/386/lib/libbio.a
/usr/local/inferno/MacOSX/386/lib/lib9.a
mk binary built successfully!
#958$458 Thu 09073022:29:31 jim@bframe4:~/work/inferno
: cp utils/mk/mk{,.bc} MacOSX/386/bin/
#959$459 Thu 09073022:29:48 jim@bframe4:~/work/inferno
: CC=llvm-gcc-4.2
PATH=/usr/local/inferno/MacOSX/386/bin/:/opt/local/bin:$PATH mk

running the build :

#974$474 Thu 09073022:59:13 jim@bframe4:~/work/inferno
: cp utils/mk/mk{,.bc} MacOSX/386/bin/
#975$475 Thu 09073022:59:25 jim@bframe4:~/work/inferno
: CC=llvm-gcc-4.2
PATH=/usr/local/inferno/MacOSX/386/bin/:/opt/local/bin:$PATH mk
Could not resolve external global address: environ
0 lli 0x0078b172 std::_Rb_tree<llvm::sys::Path,
llvm::sys::Path, std::_Identity<llvm::sys::Path>,
std::less<llvm::sys::Path>, std::allocator<llvm::sys::Path>

::insert_unique(llvm::sys::Path const&) + 7970

1 libSystem.B.dylib 0x91e1c2bb _sigtramp + 43

suggestions?
a) is macports known bad?
b) am i missing the 'not reinvent the whole makefile for llvm
compilation' FAQ ?
c) just missing a step?

the env is a mbp, with Xcode 3.1 and llvm-gcc installed, and macports
llvm/llvm-gcc installed and on the build-tools path

Using llvm-ar+llvm-ld is likely to give you bad results. On Mac,
AFAIK, the native ar and ld should do the right thing with bitcode
files, assuming you have relatively recent versions; I don't know the
details, though, since I don't have a Mac.

-Eli

the number of working permutations of [un]installing Xcode, iPhone API's, macports, and /usr/ocal/llvm[-gcc] builds seems always to dwindle, but does so without a clear point of consensus.

using native 'ld' has this effect:

#978$478 Fri 09073100:04:42 jim@bframe4:~/work/inferno
: CC=llvm-gcc-4.2 PATH=/usr/local/inferno/MacOSX/386/bin/:/opt/local/bin:$PATH ./makemk.sh
[...]
ld -L/opt/local/lib -lpthread -lm /opt/local/lib/LLVMXCore.o /opt/local/lib/LLVMSparcCodeGen.o /opt/local/lib/LLVMSparcAsmPrinter.o /opt/local/lib/LLVMPowerPCAsmPrinter.o /opt/local/lib/LLVMPowerPCCodeGen.o /opt/local/lib/LLVMPIC16.o /opt/local/lib/LLVMMSIL.o /opt/local/lib/LLVMMips.o -lLLVMLinker -lLLVMipo /opt/local/lib/LLVMInterpreter.o -lLLVMInstrumentation /opt/local/lib/LLVMIA64.o /opt/local/lib/LLVMExecutionEngine.o /opt/local/lib/LLVMJIT.o -lLLVMDebugger /opt/local/lib/LLVMCppBackend.o /opt/local/lib/LLVMCellSPUCodeGen.o /opt/local/lib/LLVMCellSPUAsmPrinter.o /opt/local/lib/LLVMCBackend.o -lLLVMBitWriter /opt/local/lib/LLVMX86AsmPrinter.o /opt/local/lib/LLVMX86CodeGen.o -lLLVMAsmParser /opt/local/lib/LLVMARMAsmPrinter.o /opt/local/lib/LLVMARMCodeGen.o -lLLVMArchive -lLLVMBitReader /opt/local/lib/LLVMAlphaCodeGen.o -lLLVMSelectionDAG /opt/local/lib/LLVMAlphaAsmPrinter.o -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMSupport -lLLVMSystem -o mk Posix.o sh.o arc.o archive.o bufblock.o env.o file.o graph.o job.o lex.o main.o match.o mk.o parse.o recipe.o rule.o run.o shprint.o symtab.o var.o varsub.o word.o /usr/local/inferno/MacOSX/386/lib/libregexp.a /usr/local/inferno/MacOSX/386/lib/libbio.a /usr/local/inferno/MacOSX/386/lib/lib9.a
ld: in Posix.o, could not parse object file Posix.o: Unknown instruction for inferred architecture i386
mk link failed