fix: enforce -O0 optimization and VRP disable to bypass compiler crashes on Pi 3B
This commit is contained in:
@ -248,21 +248,22 @@ sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.gi
|
||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
|
||||
echo "Applying clean Global Compatibility Patches..."
|
||||
|
||||
# 1. Locate OscControl.cpp and apply highlight patch
|
||||
OSC_CTRL=$(find src -name OscControl.cpp | head -n 1)
|
||||
if [ -n "$OSC_CTRL" ]; then
|
||||
cat <<'EOF_PATCH' > /tmp/highlight.patch
|
||||
# 1. Fix highlight patch
|
||||
cat <<'EOF_PATCH' > /tmp/highlight.patch
|
||||
if (m.getAddress() == "/ofxPiMapper/surface/highlight"){
|
||||
int surfaceIndex = m.getArgAsInt32(0);
|
||||
mapper->getSurfaceManager()->selectSurface(surfaceIndex);
|
||||
return;
|
||||
}
|
||||
EOF_PATCH
|
||||
sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' "$OSC_CTRL"
|
||||
rm -f /tmp/highlight.patch
|
||||
fi
|
||||
sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' src/Osc/OscControl.cpp
|
||||
rm -f /tmp/highlight.patch
|
||||
|
||||
# 2. Create a high-powered compatibility header
|
||||
# 2. Fix unique_ptr and make_unique globally (Only if std:: is missing)
|
||||
find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)unique_ptr\b/\1std::unique_ptr/g' {} +
|
||||
find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)make_unique\b/\1std::make_unique/g' {} +
|
||||
|
||||
# 3. Create a single compatibility header for C++11
|
||||
cat <<'EOF_COMPAT' > src/cpp11_compat.h
|
||||
#ifndef OFXPIMAPPER_CPP11_COMPAT_H
|
||||
#define OFXPIMAPPER_CPP11_COMPAT_H
|
||||
@ -289,18 +290,29 @@ using std::string;
|
||||
#endif
|
||||
EOF_COMPAT
|
||||
|
||||
# 3. Inject the compatibility header into ALL headers
|
||||
find src -name "*.h" -not -name "cpp11_compat.h" -exec sed -i '1i #include "cpp11_compat.h"' {} +
|
||||
# 4. Include the compat header in the main addon header
|
||||
sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h
|
||||
|
||||
# 5. Add memory header to all headers where unique_ptr is used
|
||||
for f in $(grep -l "unique_ptr" src/*.h 2>/dev/null); do
|
||||
sed -i '1i #include <memory>' "$f"
|
||||
done
|
||||
|
||||
# Build Example
|
||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
|
||||
echo "Cleaning old objects..."
|
||||
sudo -u "$REAL_USER" make clean
|
||||
|
||||
echo "Starting compilation (Stability Mode: -O1 + C++11)..."
|
||||
# Use -O1 to prevent the compiler Segfault/Internal Error seen on Pi 3B with g++ 14
|
||||
GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O1"
|
||||
sudo -u "$REAL_USER" make -j1 PLATFORM_CFLAGS="$GLOBAL_FLAGS -I$REAL_HOME/openFrameworks/addons/ofxPiMapper/src" USER_CFLAGS="$GLOBAL_FLAGS" USER_CPPFLAGS="-std=c++11"
|
||||
echo "Starting compilation (Nuclear Stability Mode: -O0 + C++11 + VRP disabled)..."
|
||||
# Force -O0 and disable VRP pass completely.
|
||||
# Also use OF_PROJECT variables to ensure these flags override the core makefile defaults.
|
||||
GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O0 -fno-tree-vrp"
|
||||
sudo -u "$REAL_USER" make -j1 \
|
||||
PLATFORM_CFLAGS="$GLOBAL_FLAGS -I$REAL_HOME/openFrameworks/addons/ofxPiMapper/src" \
|
||||
USER_CFLAGS="$GLOBAL_FLAGS" \
|
||||
USER_CPPFLAGS="-std=c++11" \
|
||||
OF_PROJECT_OPTIMIZATION_FLAGS="-O0"
|
||||
|
||||
cp bin/example_basic /usr/local/bin/ofxPiMapper
|
||||
chmod +x /usr/local/bin/ofxPiMapper
|
||||
|
||||
|
||||
Reference in New Issue
Block a user