From c9d504a147f50c0299ae96eefab12752a639fc95 Mon Sep 17 00:00:00 2001
From: cyBerta <cyberta@riseup.net>
Date: Sat, 7 Dec 2024 17:01:12 +0100
Subject: [PATCH] build bitmask-core without optimizations in build_core_dev.sh

---
 build_core_dev.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/build_core_dev.sh b/build_core_dev.sh
index 4a8e2ca..1f11756 100755
--- a/build_core_dev.sh
+++ b/build_core_dev.sh
@@ -126,23 +126,27 @@ else
 fi
 
 
+# Build Bitmask core without optimizations
+# following gcflags are applied:
+# -N: This flag disables optimizations. When optimizations are turned off, the generated code is more straightforward and easier to debug, as it retains more of the original structure of the source code.
+# -l: This flag disables inlining. Inlining is an optimization technique where the compiler replaces a function call with the actual code of the function. Disabling inlining can also make debugging easier, as it keeps the function calls intact.
 showtitle "Building Bitmask Core Android as full aar"
-gomobile bind -x -target android -ldflags="-s -w" -tags=netcgo -androidapi=21 -v -trimpath -o lib/bitmaskcore.aar ./obfsvpn/client/ ./motd ./IPtProxy/IPtProxy.go ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
+gomobile bind -x -target android -ldflags="-s -w" -gcflags="all=-N -l"  -tags=netcgo -androidapi=21 -v -trimpath -o lib/bitmaskcore.aar ./obfsvpn/client/ ./motd ./IPtProxy/IPtProxy.go ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
 
 showtitle "Building Bitmask Core Android Web as full aar including pgpverify"
-gomobile bind -x -target='android' -ldflags="-s -w" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_web.aar -v ./pgpverify ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
+gomobile bind -x -target='android' -ldflags="-s -w" -gcflags="all=-N -l" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_web.aar -v ./pgpverify ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
 
 showtitle "Building Bitmask Core Android for armv7"
-gomobile bind -target='android/arm' -ldflags="-s -w" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_arm.aar -v ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
+gomobile bind -target='android/arm' -ldflags="-s -w" -gcflags="all=-N -l" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_arm.aar -v ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
 
 showtitle "Building Bitmask Core Android for x86"
-gomobile bind -target='android/386' -ldflags="-s -w" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_x86.aar -v ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
+gomobile bind -target='android/386' -ldflags="-s -w" -gcflags="all=-N -l" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_x86.aar -v ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
 
 showtitle "Building Bitmask Core Android for arm64"
-gomobile bind -target='android/arm64' -ldflags="-s -w" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_arm64.aar -v ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
+gomobile bind -target='android/arm64' -ldflags="-s -w" -gcflags="all=-N -l" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_arm64.aar -v ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
 
 showtitle "Building Bitmask Core Android for x86_64"
-gomobile bind -target='android/amd64' -ldflags="-s -w" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_x86_64.aar -v ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
+gomobile bind -target='android/amd64' -ldflags="-s -w" -gcflags="all=-N -l" -androidapi=21 -v -tags=netcgo -trimpath -o ./lib/bitmaskcore_x86_64.aar -v ./obfsvpn/client ./IPtProxy/IPtProxy.go ./motd ./bitmask-core/pkg/mobile ./bitmask-core/pkg/mobile/mobilemodels
 
 if [[ "bitmask_android" == `pwd | rev | cut -d / -f 2 | rev` ]]; then 
     showtitle "Copying to bitmask_android main repository"
-- 
GitLab