Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass linker flags to Mono build on Android correctly #51403

Merged
merged 1 commit into from
Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libraries/Native/Unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ endif()
# Older CMake versions (3.8) do not assign the result of their tests, causing unused-value errors
# which are not distinguished from the test failing. So no error for that one.
# For clang-5.0 avoid errors like "unused variable 'err' [-Werror,-Wunused-variable]".
set(CMAKE_REQUIRED_FLAGS "-Werror -Wno-error=unused-value -Wno-error=unused-variable")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror -Wno-error=unused-value -Wno-error=unused-variable")

# Apple platforms like macOS/iOS allow targeting older operating system versions with a single SDK,
# the mere presence of a symbol in the SDK doesn't tell us whether the deployment target really supports it.
Expand Down
3 changes: 3 additions & 0 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(HOST_LINUX 1)
add_definitions(-D_GNU_SOURCE -D_REENTRANT)
add_definitions(-D_THREAD_SAFE)
add_compile_options(-Wl,-z,now)
add_compile_options(-Wl,-z,relro)
add_compile_options(-Wl,-z,noexecstack)
# The normal check fails because it uses --isystem <ndk root>/sysroot/usr/include
set(HAVE_USR_INCLUDE_MALLOC_H 1)
set(HOST_ANDROID 1)
Expand Down
11 changes: 0 additions & 11 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
<_MonoCMakeArgs Include="-DCMAKE_OSX_DEPLOYMENT_TARGET=$(macOSVersionMin)" />
<_MonoCFLAGS Condition="'$(TargetArchitecture)' == 'arm64'" Include="-arch arm64" />
<_MonoCXXFLAGS Condition="'$(TargetArchitecture)' == 'arm64'" Include="-arch arm64" />
<_MonoLDFLAGS Condition="'$(TargetArchitecture)' == 'arm64'" Include="-arch arm64" />
<!-- Force running as arm64 even when invoked from an x86 msbuild process -->
<_MonoBuildEnv Condition="'$(BuildArchitecture)' == 'arm64'" Include="arch -arch arm64" />
</ItemGroup>
Expand All @@ -264,7 +263,6 @@
<_MonoCXXFlags Condition="'$(TargetArchitecture)' == 'arm64'" Include="-target arm64-apple-ios14.2-macabi" />
<_MonoCXXFlags Condition="'$(TargetArchitecture)' == 'x64'" Include="-target x86_64-apple-ios13.5-macabi" />
<_MonoCXXFLAGS Condition="'$(TargetArchitecture)' == 'arm64'" Include="-arch arm64" />
<_MonoLDFLAGS Condition="'$(TargetArchitecture)' == 'arm64'" Include="-arch arm64" />
<!-- Force running as arm64 even when invoked from an x86 msbuild process -->
<_MonoBuildEnv Condition="'$(BuildArchitecture)' == 'arm64'" Include="arch -arch arm64" />
</ItemGroup>
Expand Down Expand Up @@ -378,15 +376,6 @@
<_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-DSK_RELEASE" />
<_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-DNDEBUG" />
<_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-UDEBUG" />

<_MonoLDFLAGS Include="-z now" />
<_MonoLDFLAGS Include="-z relro" />
<_MonoLDFLAGS Include="-z noexecstack" />
<_MonoLDFLAGS Include="-ldl" />
<_MonoLDFLAGS Include="-lm" />
<_MonoLDFLAGS Include="-llog" />
<_MonoLDFLAGS Include="-lc" />
<_MonoLDFLAGS Include="-lgcc" />
</ItemGroup>
<!-- Linux options -->
<ItemGroup Condition="'$(TargetsLinux)' == true">
Expand Down