@@ -16,27 +16,37 @@ rm -rf /rocksdb-local-build/*
1616cp -r /rocksdb-host/* /rocksdb-local-build
1717cd /rocksdb-local-build
1818
19- # Use scl devtoolset if available
19+ # Detect and enable devtoolset if available
20+ DEVTOOLSET=" "
2021if hash scl 2> /dev/null; then
21- if scl --list | grep -q ' devtoolset-8' ; then
22- # CentOS 6+
23- scl enable devtoolset-8 ' make clean-not-downloaded'
24- scl enable devtoolset-8 " PORTABLE=1 J=$J make -j$J rocksdbjavastatic"
22+ # Check for devtoolsets in order of preference (newer first)
23+ if scl --list | grep -q ' devtoolset-12' ; then
24+ DEVTOOLSET=" devtoolset-12"
25+ elif scl --list | grep -q ' devtoolset-11' ; then
26+ DEVTOOLSET=" devtoolset-11"
27+ elif scl --list | grep -q ' devtoolset-10' ; then
28+ DEVTOOLSET=" devtoolset-10"
29+ elif scl --list | grep -q ' devtoolset-9' ; then
30+ DEVTOOLSET=" devtoolset-9"
31+ elif scl --list | grep -q ' devtoolset-8' ; then
32+ DEVTOOLSET=" devtoolset-8"
2533 elif scl --list | grep -q ' devtoolset-7' ; then
26- # CentOS 6+
27- scl enable devtoolset-7 ' make clean-not-downloaded'
28- scl enable devtoolset-7 " PORTABLE=1 J=$J make -j$J rocksdbjavastatic"
34+ DEVTOOLSET=" devtoolset-7"
2935 elif scl --list | grep -q ' devtoolset-2' ; then
30- # CentOS 5 or 6
31- scl enable devtoolset-2 ' make clean-not-downloaded'
32- scl enable devtoolset-2 " PORTABLE=1 J=$J make -j$J rocksdbjavastatic"
33- else
34- echo " Could not find devtoolset"
35- exit 1;
36+ DEVTOOLSET=" devtoolset-2"
3637 fi
38+ fi
39+
40+ # Build with devtoolset if available, otherwise use system compiler
41+ # Add -Wno-error=restrict for GCC 12+ to avoid false positive warnings
42+ if [ -n " $DEVTOOLSET " ]; then
43+ echo " Using $DEVTOOLSET "
44+ scl enable $DEVTOOLSET " bash -c 'make clean-not-downloaded'"
45+ scl enable $DEVTOOLSET " bash -c 'PORTABLE=1 J=$J make -j$J rocksdbjavastatic'"
3746else
47+ echo " No SCL devtoolset found, falling back to system compiler"
3848 make clean-not-downloaded
39- PORTABLE=1 make -j$J rocksdbjavastatic
49+ PORTABLE=1 J= $J make -j$J rocksdbjavastatic
4050fi
4151
4252cp java/target/librocksdbjni-linux* .so java/target/rocksdbjni-* -linux* .jar java/target/rocksdbjni-* -linux* .jar.sha1 /rocksdb-java-target
0 commit comments