Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#15702 closed bug (fixed)

makefile_engine: can't build 64bit drivers

Reported by: X512 Owned by: bonefish
Priority: normal Milestone: R1/beta3
Component: Build System Version: R1/Development
Keywords: Cc:
Blocked By: Blocking: #15832
Platform: x86-64

Description (last modified by X512)

This is hrev53780 x86_64.

When building test driver on x86_64, link fails:

cc -o "objects.x86_64-cc8-release/acpi_test"    objects.x86_64-cc8-release/acpi_test.o  -nostdlib /boot/system/develop/lib/_KERNEL_ /boot/system/develop/lib/haiku_version_glue.o  -L./    
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc8-release/acpi_test.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
/boot/system/develop/etc/makefile-engine:246: recipe for target 'objects.x86_64-cc8-release/acpi_test' failed
make: *** [objects.x86_64-cc8-release/acpi_test] Error 1

If add -fPIC to compiler options, drivers compiles, but don't load, bad data error is written in syslog.

32 bit version compile and run without problems.

Change History (9)

comment:1 by X512, 4 years ago

Description: modified (diff)

in reply to:  2 comment:3 by X512, 4 years ago

Replying to diver:

https://github.com/haikuports/haikuports/issues/1768 seems to be related.

Thanks. adding -shared -Xlinker -soname=$(NAME) -z max-page-size=0x1000 to linker flags fixes issue. makefile-engine need to be adjusted. I don't know is it a best solution or not, advice from x86_64 kernel build system developer is required.

comment:4 by waddlesplash, 4 years ago

That argument is indeed used under x86_64 generally: https://xref.landonf.org/source/xref/haiku/build/jam/ArchitectureRules#458

comment:5 by X512, 4 years ago

Does PIC needed for x86_64 kernel drivers? makefile-engine disables PIC for drivers: https://xref.landonf.org/source/xref/haiku/data/develop/makefile-engine#43.

comment:6 by diver, 4 years ago

Blocking: 15832 added

comment:7 by nielx, 4 years ago

I added the line from comment:3 in the LINKFLAGS, but I still get a compiler error.

mkdir -p objects.x86_64-cc8-release; \
mkdepend  -I./ -p .c:objects.x86_64-cc8-release/%n.o -m -f "objects.x86_64-cc8-release/i2c_hid.d" i2c_hid.c
cc -c i2c_hid.c -iquote./  -iquote./  -D_KERNEL_MODE=1 -fno-pic -O3    -o "objects.x86_64-cc8-release/i2c_hid.o"
cc -o "objects.x86_64-cc8-release/i2c_hid"      objects.x86_64-cc8-release/i2c_hid.o  -nostdlib /boot/system/develop/lib/_KERNEL_ /boot/system/develop/lib/haiku_version_glue.o  -L./    -shared -Xlinker -soname=i2c_hid -z max-page-size=0x1000
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc8-release/i2c_hid.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
/boot/system/develop/etc/makefile-engine:246: recipe for target 'objects.x86_64-cc8-release/i2c_hid' failed
make: *** [objects.x86_64-cc8-release/i2c_hid] Error 

comment:8 by diver, 3 years ago

Resolution: fixed
Status: newclosed

Fixed in hrev54689.

comment:9 by korli, 3 years ago

Milestone: UnscheduledR1/beta3
Note: See TracTickets for help on using tickets.