fix: enforce -O0 optimization and VRP disable to bypass compiler crashes on Pi 3B
This commit is contained in:
@ -248,9 +248,7 @@ sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.gi
|
|||||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
|
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
|
||||||
echo "Applying clean Global Compatibility Patches..."
|
echo "Applying clean Global Compatibility Patches..."
|
||||||
|
|
||||||
# 1. Locate OscControl.cpp and apply highlight patch
|
# 1. Fix highlight patch
|
||||||
OSC_CTRL=$(find src -name OscControl.cpp | head -n 1)
|
|
||||||
if [ -n "$OSC_CTRL" ]; then
|
|
||||||
cat <<'EOF_PATCH' > /tmp/highlight.patch
|
cat <<'EOF_PATCH' > /tmp/highlight.patch
|
||||||
if (m.getAddress() == "/ofxPiMapper/surface/highlight"){
|
if (m.getAddress() == "/ofxPiMapper/surface/highlight"){
|
||||||
int surfaceIndex = m.getArgAsInt32(0);
|
int surfaceIndex = m.getArgAsInt32(0);
|
||||||
@ -258,11 +256,14 @@ if [ -n "$OSC_CTRL" ]; then
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EOF_PATCH
|
EOF_PATCH
|
||||||
sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' "$OSC_CTRL"
|
sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' src/Osc/OscControl.cpp
|
||||||
rm -f /tmp/highlight.patch
|
rm -f /tmp/highlight.patch
|
||||||
fi
|
|
||||||
|
|
||||||
# 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
|
cat <<'EOF_COMPAT' > src/cpp11_compat.h
|
||||||
#ifndef OFXPIMAPPER_CPP11_COMPAT_H
|
#ifndef OFXPIMAPPER_CPP11_COMPAT_H
|
||||||
#define OFXPIMAPPER_CPP11_COMPAT_H
|
#define OFXPIMAPPER_CPP11_COMPAT_H
|
||||||
@ -289,18 +290,29 @@ using std::string;
|
|||||||
#endif
|
#endif
|
||||||
EOF_COMPAT
|
EOF_COMPAT
|
||||||
|
|
||||||
# 3. Inject the compatibility header into ALL headers
|
# 4. Include the compat header in the main addon header
|
||||||
find src -name "*.h" -not -name "cpp11_compat.h" -exec sed -i '1i #include "cpp11_compat.h"' {} +
|
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
|
# Build Example
|
||||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
|
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
|
||||||
echo "Cleaning old objects..."
|
echo "Cleaning old objects..."
|
||||||
sudo -u "$REAL_USER" make clean
|
sudo -u "$REAL_USER" make clean
|
||||||
|
|
||||||
echo "Starting compilation (Stability Mode: -O1 + C++11)..."
|
echo "Starting compilation (Nuclear Stability Mode: -O0 + C++11 + VRP disabled)..."
|
||||||
# Use -O1 to prevent the compiler Segfault/Internal Error seen on Pi 3B with g++ 14
|
# Force -O0 and disable VRP pass completely.
|
||||||
GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O1"
|
# Also use OF_PROJECT variables to ensure these flags override the core makefile defaults.
|
||||||
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"
|
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
|
cp bin/example_basic /usr/local/bin/ofxPiMapper
|
||||||
chmod +x /usr/local/bin/ofxPiMapper
|
chmod +x /usr/local/bin/ofxPiMapper
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user