Skip to content

Commit 8602581

Browse files
gugavarojonpryor
authored andcommitted
[java-interop] Enabling -fPIC on Linux build - part 2 (#518)
We recently changed the build options to enable fPIC on Linux builds in commit 10ba45a, but there were a couple of places still missing. The `src/java-interop` build fails on Linux Ubuntu 19.10: gcc -g -shared -m64 -o bin/TestDebug/libNativeTiming.so tests/NativeTiming/timing.c -I/usr/lib/jvm/java-1.8.0-openjdk-amd64/include -I/usr/lib/jvm/java-1.8.0-openjdk-amd64/include/linux /usr/bin/ld: /tmp/ccmuRrxZ.o: relocation R_X86_64_PC32 against symbol `foo_void_timing' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: nonrepresentable section on output collect2: error: ld returned 1 exit status Update the Linux build to use `gcc -fPIC` so that `src/java-interop` can be linked successfully.
1 parent ff3081d commit 8602581

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ NATIVE_TIMING_LIB = libNativeTiming$(NATIVE_EXT)
109109

110110
bin/Test$(CONFIGURATION)/$(NATIVE_TIMING_LIB): tests/NativeTiming/timing.c $(wildcard $(JI_JDK_INCLUDE_PATHS)/jni.h)
111111
mkdir -p `dirname "$@"`
112-
gcc -g -shared -m64 -o $@ $< $(JI_JDK_INCLUDE_PATHS:%=-I%)
112+
gcc -g -shared -m64 -fPIC -o $@ $< $(JI_JDK_INCLUDE_PATHS:%=-I%)
113113

114114
# Usage: $(call TestAssemblyTemplate,assembly-basename)
115115
define TestAssemblyTemplate

src/java-interop/java-interop.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<_Libs>$(MonoLibs)</_Libs>
4444
<_Files>@(ClCompile->'obj\$(Configuration)\%(Filename).o', ' ')</_Files>
4545
</PropertyGroup>
46-
<Exec Command="gcc -g -shared -m64 -std=c99 -o &quot;$(_MacLib)&quot; $(_LinkFlags) $(_Libs) $(_Files)" />
46+
<Exec Command="gcc -g -shared -m64 -std=c99 -fPIC -o &quot;$(_MacLib)&quot; $(_LinkFlags) $(_Libs) $(_Files)" />
4747
<!-- Mono 4.4.0 (mono-4.4.0-branch/a3fabf1) has an incorrect shared library name. Fix it -->
4848
<Exec Command="install_name_tool -change /private/tmp/source-mono-4.4.0/bockbuild-mono-4.4.0-branch/profiles/mono-mac-xamarin/package-root/lib/libmonosgen-2.0.1.dylib /Library/Frameworks/Mono.framework/Libraries/libmonosgen-2.0.1.dylib &quot;$(_MacLib)&quot;" />
4949
</Target>

tests/invocation-overhead/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jni.c jni.cs: $(JNIENV_GEN)
2828
$(RUNTIME) $< jni.cs jni.c
2929

3030
libjava-interop.dylib: jni.c
31-
gcc -g -shared -o $@ $< -m64 -DJI_DLL_EXPORT -fvisibility=hidden $(JI_JDK_INCLUDE_PATHS:%=-I%)
31+
gcc -g -shared -fPIC -o $@ $< -m64 -DJI_DLL_EXPORT -fvisibility=hidden $(JI_JDK_INCLUDE_PATHS:%=-I%)
3232

3333
run:
3434
$(RUNTIME) test-overheads.exe

0 commit comments

Comments
 (0)