Skip to content

Instantly share code, notes, and snippets.

@ochafik
Last active February 3, 2022 01:27
Show Gist options
  • Select an option

  • Save ochafik/ccdc5eb520ed75dcdc7f0267d9499e35 to your computer and use it in GitHub Desktop.

Select an option

Save ochafik/ccdc5eb520ed75dcdc7f0267d9499e35 to your computer and use it in GitHub Desktop.
Build an optimized OpenSCAD locally on MacOS X (checkout parallel fork)
mkdir build
( cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DEXPERIMENTAL=1 )
( cd build && time make -j12 )
( cd build/tests && time ctest -j12 -E 'edges_view-options-tests|nef3_broken' )
( cd build/tests && time ctest -j12 -R 'fastcsg.*' )
mkdir build_same_kernel
( cd build_same_kernel && cmake .. -DCMAKE_BUILD_TYPE=Release -DEXPERIMENTAL=1 -DFAST_CSG_SAME_KERNEL=1 )
( cd build_same_kernel && time make -j12 )
( cd build_same_kernel/tests && time ctest -j12 -E 'edges_view-options-tests|nef3_broken' )
( cd build/tests && time ctest -j12 -R 'fastcsg.*' )
#!/bin/bash
#
# Trivial to adapt to Linux (just check your compiler settings if not using clang)
#
# TODO: test removing the `add_definitions(-DEIGEN_DONT_ALIGN)` from CMakeLists.txt, at least if(APPLE)
# Stock OpenSCAD
# git clone https://github.com/openscad/openscad
# Fork with some parallelism and extra lazy features
# See changes: https://github.com/openscad/openscad/compare/master...ochafik:faster-integ-1
git clone https://github.com/ochafik/openscad
git checkout faster-integ-1
./scripts/macosx-build-homebrew.sh
cd openscad
rm -fR objects .qmake.cache
# See https://clang.llvm.org/docs/ThinLTO.html
# and https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
export qmake_args=(
CONFIG+=experimental
CONFIG+=snapshot
CONFIG+=info
CONFIG-=debug
CONFIG+=optimize_full
QMAKE_CXXFLAGS+=-march=native
QMAKE_CXXFLAGS+=-flto=full
QMAKE_LFLAGS+=-flto=full
#QMAKE_CXXFLAGS+=-ffast-math
#QMAKE_CXXFLAGS+=-DCGAL_NEF3_INTERSECTION_BY_KDTREE
)
qmake openscad.pro "${qmake_args[@]}"
make clean && make -j12
time ./OpenSCAD.app/Contents/MacOS/OpenSCAD \
--enable=lazy-union \
--enable=lazy-module \
--enable=flatten-children \
--enable=push-transforms \
--enable=difference-union \
--enable=parallelize \
-o output.stl Benchy.scad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment