[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#837359: ocaml: FTBFS on -fPIE binNMU on armhf - test failure



Ximin Luo:
> Ximin Luo:
>>
>> It's possible OCaml itself is to blame:
>>
>> asmcomp/arm/emit.mlp:
>>     if nh = 0l then begin
>>       `	movw	{emit_reg dst}, #{emit_int32 nl}\n`; 1
>>     end else if Int32.logand nl 0xffl = nl then begin
>>       `	movs	{emit_reg dst}, #{emit_int32 nl}\n`;
>>       `	movt	{emit_reg dst}, #{emit_int32 nh}\n`; 2
>>     end else begin
>>       `	movw	{emit_reg dst}, #{emit_int32 nl}\n`;
>>       `	movt	{emit_reg dst}, #{emit_int32 nh}\n`; 2
>>     end
>>

Sorry, wrong snippet. The above code is not relevant for what we're observing below. The correct snippet is this:

let emit_load_symbol_addr dst s =
  if !Clflags.pic_code then begin
    [..]
  end else if !arch > ARMv6 && not !Clflags.dlcode && !fastcode_flag then begin
    `	movw	{emit_reg dst}, #:lower16:{emit_symbol s}\n`;
    `	movt	{emit_reg dst}, #:upper16:{emit_symbol s}\n`;
    2

Note that !arch in ocaml means "get the current value of the mutable reference 'arch'".

It looks like they already wrote the working code, it's just not being emitted here. So I just need to figure out how to make Cflags.pic_code true, which shouldn't be too hard. I will try this tomorrow when I'm less tired.

>> Judging by http://lists.denx.de/pipermail/u-boot/2013-September/163154.html this might be invalid for ARM and PIC.
>>
>> (sid_armhf-dchroot)infinity0@harris:~/ocaml/testsuite/tests/asmcomp$ rm quicksort2.s quicksort2.o
>>
>> (sid_armhf-dchroot)infinity0@harris:~/ocaml/testsuite/tests/asmcomp$ make CASES=quicksort2  MLCASES= MLCASES_FLAMBDA=
>> make[1]: Entering directory '/home/infinity0/ocaml/testsuite/tests/asmcomp'
>> make[2]: Entering directory '/home/infinity0/ocaml/testsuite/tests/asmcomp'
>> make[2]: Nothing to be done for 'arch'.
>> make[2]: 'codegen' is up to date.
>> make[2]: Leaving directory '/home/infinity0/ocaml/testsuite/tests/asmcomp'
>> make[2]: Entering directory '/home/infinity0/ocaml/testsuite/tests/asmcomp'
>>  ... testing 'quicksort2':make[3]: Entering directory '/home/infinity0/ocaml/testsuite/tests/asmcomp'
>> /usr/bin/ld: quicksort2.o: relocation R_ARM_THM_MOVW_ABS_NC against `cmp' can not be used when making a shared object; recompile with -fPIC
>> quicksort2.o: error adding symbols: Bad value
>> collect2: error: ld returned 1 exit status
>>  => failed
>> make[3]: Leaving directory '/home/infinity0/ocaml/testsuite/tests/asmcomp'
>> make[2]: Leaving directory '/home/infinity0/ocaml/testsuite/tests/asmcomp'
>> make[1]: Leaving directory '/home/infinity0/ocaml/testsuite/tests/asmcomp'
>>
>> (sid_armhf-dchroot)infinity0@harris:~/ocaml/testsuite/tests/asmcomp$ grep -n mov[tw] quicksort2.s
>> 138:    movw    r3, #:lower16:cmp
>> 139:    movt    r3, #:upper16:cmp
>>
>> Could someone else more familiar with ARM and/or OCaml comment please?
>>
> 
> And in fact manually editing quicksort2.s to change the movt/w expressions to "r3, 0", commenting out the "codegen" part of the .cmm.o rule in Makefile.common, then running the above test command again, will make it pass. So the emitted instructions are likely what's at fault, but I don't know ARM well enough to suggest how to fix it properly.
> 
> X
> 

-- 
GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE
https://github.com/infinity0/pubkeys.git


Reply to: