I'm beginning to think that it's not actually compiling statically. I set up a fresh install of OS X, installed Python, installed XCode, installed macports, libiconv, libxml2, zlib, libxslt, and tried building statically with the following options in the setup file and the following command: STATIC_INCLUDE_DIRS = ["/opt/local/include", "/opt/local/include/libxml2"] STATIC_LIBRARY_DIRS = ["/opt/local/lib"] STATIC_CFLAGS = ["-liconv", "-lz"] euterpe:~/lxml-2.0 jon$ export DYLD_LIBRARY_PATH=/opt/local/lib euterpe:~/lxml-2.0 jon$ python setup.py bdist_egg --static However, I noticed (a) that the gcc line still says -dynamic and (b) the file size of etree.so does not differ whether or not I build with the --static option. And I still get the same segfaults. Building lxml version 2.0. NOTE: Trying to build without Cython, pre-generated 'src/lxml/etree.c' needs to be available. running bdist_egg running egg_info writing src/lxml.egg-info/PKG-INFO writing top-level names to src/lxml.egg-info/top_level.txt writing dependency_links to src/lxml.egg-info/dependency_links.txt reading manifest file 'src/lxml.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files found matching 'doc/pyrex.txt' writing manifest file 'src/lxml.egg-info/SOURCES.txt' installing library code to build/bdist.macosx-10.3-fat/egg running install_lib running build_py creating build creating build/lib.macosx-10.3-fat-2.5 creating build/lib.macosx-10.3-fat-2.5/lxml copying src/lxml/__init__.py -> build/lib.macosx-10.3-fat-2.5/lxml copying src/lxml/_elementpath.py -> build/lib.macosx-10.3-fat-2.5/lxml copying src/lxml/builder.py -> build/lib.macosx-10.3-fat-2.5/lxml copying src/lxml/cssselect.py -> build/lib.macosx-10.3-fat-2.5/lxml copying src/lxml/doctestcompare.py -> build/lib.macosx-10.3-fat-2.5/lxml copying src/lxml/ElementInclude.py -> build/lib.macosx-10.3-fat-2.5/lxml copying src/lxml/htmlbuilder.py -> build/lib.macosx-10.3-fat-2.5/lxml copying src/lxml/sax.py -> build/lib.macosx-10.3-fat-2.5/lxml copying src/lxml/usedoctest.py -> build/lib.macosx-10.3-fat-2.5/lxml creating build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/__init__.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/_dictmixin.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/_diffcommand.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/builder.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/clean.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/defs.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/diff.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/ElementSoup.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/formfill.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/setmixin.py -> build/lib.macosx-10.3-fat-2.5/lxml/html copying src/lxml/html/usedoctest.py -> build/lib.macosx-10.3-fat-2.5/lxml/html running build_ext building 'lxml.etree' extension creating build/temp.macosx-10.3-fat-2.5 creating build/temp.macosx-10.3-fat-2.5/src creating build/temp.macosx-10.3-fat-2.5/src/lxml gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -I/opt/local/include -I/opt/local/include/libxml2 -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.3-fat-2.5/src/lxml/lxml.etree.o -w -liconv -lz i686-apple-darwin8-gcc-4.0.1: -liconv: linker input file unused because linking not done i686-apple-darwin8-gcc-4.0.1: -lz: linker input file unused because linking not done powerpc-apple-darwin8-gcc-4.0.1: -liconv: linker input file unused because linking not done powerpc-apple-darwin8-gcc-4.0.1: -lz: linker input file unused because linking not done gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.5/src/lxml/lxml.etree.o -L/opt/local/lib -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.3-fat-2.5/lxml/etree.so building 'lxml.objectify' extension gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -I/opt/local/include -I/opt/local/include/libxml2 -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.3-fat-2.5/src/lxml/lxml.objectify.o -w -liconv -lz i686-apple-darwin8-gcc-4.0.1: -liconv: linker input file unused because linking not done i686-apple-darwin8-gcc-4.0.1: -lz: linker input file unused because linking not done powerpc-apple-darwin8-gcc-4.0.1: -liconv: linker input file unused because linking not done powerpc-apple-darwin8-gcc-4.0.1: -lz: linker input file unused because linking not done gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.5/src/lxml/lxml.objectify.o -L/opt/local/lib -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.3-fat-2.5/lxml/objectify.so building 'lxml.pyclasslookup' extension gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -I/opt/local/include -I/opt/local/include/libxml2 -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c src/lxml/lxml.pyclasslookup.c -o build/temp.macosx-10.3-fat-2.5/src/lxml/lxml.pyclasslookup.o -w -liconv -lz i686-apple-darwin8-gcc-4.0.1: -liconv: linker input file unused because linking not done i686-apple-darwin8-gcc-4.0.1: -lz: linker input file unused because linking not done powerpc-apple-darwin8-gcc-4.0.1: -liconv: linker input file unused because linking not done powerpc-apple-darwin8-gcc-4.0.1: -lz: linker input file unused because linking not done gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.5/src/lxml/lxml.pyclasslookup.o -L/opt/local/lib -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.3-fat-2.5/lxml/pyclasslookup.so creating build/bdist.macosx-10.3-fat creating build/bdist.macosx-10.3-fat/egg creating build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/__init__.py -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/_elementpath.py -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/builder.py -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/cssselect.py -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/doctestcompare.py -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/ElementInclude.py -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/etree.so -> build/bdist.macosx-10.3-fat/egg/lxml creating build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/__init__.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/_dictmixin.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/_diffcommand.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/builder.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/clean.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/defs.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/diff.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/ElementSoup.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/formfill.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/setmixin.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/html/usedoctest.py -> build/bdist.macosx-10.3-fat/egg/lxml/html copying build/lib.macosx-10.3-fat-2.5/lxml/htmlbuilder.py -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/objectify.so -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/pyclasslookup.so -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/sax.py -> build/bdist.macosx-10.3-fat/egg/lxml copying build/lib.macosx-10.3-fat-2.5/lxml/usedoctest.py -> build/bdist.macosx-10.3-fat/egg/lxml byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/__init__.py to __init__.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/_elementpath.py to _elementpath.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/builder.py to builder.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/cssselect.py to cssselect.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/doctestcompare.py to doctestcompare.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/ElementInclude.py to ElementInclude.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/__init__.py to __init__.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/_dictmixin.py to _dictmixin.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/_diffcommand.py to _diffcommand.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/builder.py to builder.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/clean.py to clean.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/defs.py to defs.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/diff.py to diff.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/ElementSoup.py to ElementSoup.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/formfill.py to formfill.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/setmixin.py to setmixin.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/html/usedoctest.py to usedoctest.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/htmlbuilder.py to htmlbuilder.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/sax.py to sax.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/usedoctest.py to usedoctest.pyc creating stub loader for lxml/etree.so creating stub loader for lxml/objectify.so creating stub loader for lxml/pyclasslookup.so byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/etree.py to etree.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/objectify.py to objectify.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/lxml/pyclasslookup.py to pyclasslookup.pyc creating build/bdist.macosx-10.3-fat/egg/EGG-INFO writing src/lxml.egg-info/native_libs.txt copying src/lxml.egg-info/PKG-INFO -> build/bdist.macosx-10.3-fat/egg/EGG-INFO copying src/lxml.egg-info/SOURCES.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO copying src/lxml.egg-info/dependency_links.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO copying src/lxml.egg-info/native_libs.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO copying src/lxml.egg-info/not-zip-safe -> build/bdist.macosx-10.3-fat/egg/EGG-INFO copying src/lxml.egg-info/top_level.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO creating dist creating 'dist/lxml-2.0-py2.5-macosx-10.3-fat.egg' and adding 'build/bdist.macosx-10.3-fat/egg' to it removing 'build/bdist.macosx-10.3-fat/egg' (and everything under it) euterpe:~/lxml-2.0 jon$ ls -lh dist/ total 3616 -rw-r--r-- 1 jon jon 1M Feb 2 13:03 lxml-2.0-py2.5-macosx-10.3-fat.egg