Skip to content

Commit

Permalink
Make builds 16KB compliant (#38)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/488551667048375/1209000029029641/f

### Description
Make sure the builds are 16KB compatible

### Steps to test this PR
Script to be used during testing
```bash
find . -type f -name "*.so" | while read -r file; do
    result=$(objdump -p "$file" | grep LOAD | awk '{ print $NF }' | head -1)
    echo "$file: $result"
done
```
_Test_
- [x] in the main branch, `cd android` folder and run `./gradlew clean build`
- [x] run the script above
- [x] all `.so` files result in `2**12` alignment
- [x] change to this branch and again `cd android` folder and run `./gradlew clean build`
- [x] run the script above
- [x] all `.so` files result in `2**14` alignment
  • Loading branch information
aitorvs authored Dec 20, 2024
1 parent 2f20577 commit b47f5e0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion android/netguard/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ target_link_libraries( # Specifies the target library.
# included in the NDK.
${log-lib} )

#Ensure 16KB compatibility
target_link_options(netguard PRIVATE "-Wl,-z,max-page-size=16384")

# Makefile requires this to be with "/" to link correctly
file(TO_CMAKE_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} OUT_PATH_CMAKE)
add_custom_target(libwg-go.so WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/wireguard" COMMENT "Building wireguard-go" VERBATIM COMMAND make
Expand All @@ -73,7 +76,7 @@ add_custom_target(libwg-go.so WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../
ANDROID_PACKAGE_NAME=${ANDROID_PACKAGE_NAME}
GRADLE_USER_HOME=${GRADLE_USER_HOME}
CFLAGS=${CMAKE_C_FLAGS}\ -Wno-unused-command-line-argument
LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}\ -fuse-ld=gold
LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}\ -fuse-ld=gold\ -Wl,-z,max-page-size=16384
DESTDIR=${OUT_PATH_CMAKE}
BUILDDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../generated-src
)
Expand Down

0 comments on commit b47f5e0

Please sign in to comment.