Skip to content

Some symbol names somehow depend on the source directory location #7133

Closed

Description

I've tried many different things, optimizations on, off, debug-info, no debug-info, and that made no difference. Here are steps to reproduce that "works" every time for me (using --release reduces the number of symbols affected, since so many are eliminated in this case):

$ cargo --version
cargo 1.36.0 (c4fcfb725 2019-05-15)
$ rustc --version
rustc 1.36.0 (a53f9df32 2019-07-03)
$ cargo new t1
$ cp -r t1 t2
$ cd t1
$ CARGO_INCREMENTAL=0 cargo rustc --release -- --remap-path-prefix=$PWD=. -C codegen-units=1
   Compiling t1 v0.1.0 (/tmp/t1)
    Finished release [optimized] target(s) in 0.29s
$ cd ../t2
$ CARGO_INCREMENTAL=0 cargo rustc --release -- --remap-path-prefix=$PWD=. -C codegen-units=1
   Compiling t1 v0.1.0 (/tmp/t2)
    Finished release [optimized] target(s) in 0.27s
$ cd ..
$ diffoscope t[12]/target/release/t1
--- t1/target/release/t1
+++ t2/target/release/t1
├── readelf --wide --symbols {}
│ @@ -129,20 +129,20 @@
│      41: 0000000000004180     0 FUNC    LOCAL  DEFAULT   14 deregister_tm_clones
│      42: 00000000000041b0     0 FUNC    LOCAL  DEFAULT   14 register_tm_clones
│      43: 00000000000041f0     0 FUNC    LOCAL  DEFAULT   14 __do_global_dtors_aux
│      44: 0000000000030038     1 OBJECT  LOCAL  DEFAULT   28 completed.7325
│      45: 000000000002e168     0 OBJECT  LOCAL  DEFAULT   23 __do_global_dtors_aux_fini_array_entry
│      46: 0000000000004230     0 FUNC    LOCAL  DEFAULT   14 frame_dummy
│      47: 000000000002e160     0 OBJECT  LOCAL  DEFAULT   22 __frame_dummy_init_array_entry
│ -    48: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS t1.akdfy859-cgu.0
│ -    49: 0000000000004270    71 FUNC    LOCAL  DEFAULT   14 _ZN2t14main17hc5d68b83d81d2494E
│ -    50: 0000000000004240     7 FUNC    LOCAL  DEFAULT   14 _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h5d4bc421a6240ab3E
│ -    51: 0000000000004250     7 FUNC    LOCAL  DEFAULT   14 _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h5825211e365a5efdE
│ -    52: 0000000000004260     1 FUNC    LOCAL  DEFAULT   14 _ZN4core3ptr18real_drop_in_place17h5e90b097dfd8451cE
│ -    53: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS 45oartxzl9zxvu7a
│ +    48: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS t1.aywbp33t-cgu.0
│ +    49: 0000000000004270    71 FUNC    LOCAL  DEFAULT   14 _ZN2t14main17h18e047a624f74a19E
│ +    50: 0000000000004240     7 FUNC    LOCAL  DEFAULT   14 _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hbdbfcf746a94100cE
│ +    51: 0000000000004250     7 FUNC    LOCAL  DEFAULT   14 _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17hd8c4386471704473E
│ +    52: 0000000000004260     1 FUNC    LOCAL  DEFAULT   14 _ZN4core3ptr18real_drop_in_place17h66f94376c5a38a4aE
│ +    53: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS 3d9navqc0k273olq
│      54: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS std.7lpsvnrb-cgu.0
│      55: 000000000002c7d4     0 NOTYPE  LOCAL  DEFAULT   19 GCC_except_table1000
│      56: 000000000002c800     0 NOTYPE  LOCAL  DEFAULT   19 GCC_except_table1002
│      57: 000000000002c81c     0 NOTYPE  LOCAL  DEFAULT   19 GCC_except_table1006
│      58: 000000000002ba48     0 NOTYPE  LOCAL  DEFAULT   19 GCC_except_table102
│      59: 000000000002c838     0 NOTYPE  LOCAL  DEFAULT   19 GCC_except_table1031
│      60: 000000000002c864     0 NOTYPE  LOCAL  DEFAULT   19 GCC_except_table1039
├── objdump --line-numbers --disassemble --demangle --reloc --section=.text {}
│ @@ -75,42 +75,42 @@
│  frame_dummy():
│      4230:	e9 7b ff ff ff       	jmpq   41b0 <register_tm_clones>
│      4235:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
│      423c:	00 00 00 
│      423f:	90                   	nop
│  
│  0000000000004240 <std::rt::lang_start::{{closure}}>:
│ -_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h5d4bc421a6240ab3E():
│ +_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hbdbfcf746a94100cE():
│      4240:	50                   	push   %rax
│      4241:	ff 17                	callq  *(%rdi)
│      4243:	31 c0                	xor    %eax,%eax
│      4245:	59                   	pop    %rcx
│      4246:	c3                   	retq   
│      4247:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
│      424e:	00 00 
│  
│  0000000000004250 <core::ops::function::FnOnce::call_once{{vtable-shim}}>:
│ -_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h5825211e365a5efdE():
│ +_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17hd8c4386471704473E():
│      4250:	50                   	push   %rax
│      4251:	ff 17                	callq  *(%rdi)
│      4253:	31 c0                	xor    %eax,%eax
│      4255:	59                   	pop    %rcx
│      4256:	c3                   	retq   
│      4257:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
│      425e:	00 00 
│  
│  0000000000004260 <core::ptr::real_drop_in_place>:
│ -_ZN4core3ptr18real_drop_in_place17h5e90b097dfd8451cE():
│ +_ZN4core3ptr18real_drop_in_place17h66f94376c5a38a4aE():
│      4260:	c3                   	retq   
│      4261:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
│      4268:	00 00 00 
│      426b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
│  
│  0000000000004270 <t1::main>:
│ -_ZN2t14main17hc5d68b83d81d2494E():
│ +_ZN2t14main17h18e047a624f74a19E():
│      4270:	48 83 ec 38          	sub    $0x38,%rsp
│      4274:	48 8d 05 25 9f 02 00 	lea    0x29f25(%rip),%rax        
│      427b:	48 89 44 24 08       	mov    %rax,0x8(%rsp)
│      4280:	48 c7 44 24 10 01 00 	movq   $0x1,0x10(%rsp)
│      4287:	00 00 
│      4289:	48 c7 44 24 18 00 00 	movq   $0x0,0x18(%rsp)
│      4290:	00 00
├── readelf --wide --decompress --hex-dump=.strtab {}
│ @@ -5,33 +5,33 @@
│    0x00000020 005f5f64 6f5f676c 6f62616c 5f64746f .__do_global_dto
│    0x00000030 72735f61 75780063 6f6d706c 65746564 rs_aux.completed
│    0x00000040 2e373332 35005f5f 646f5f67 6c6f6261 .7325.__do_globa
│    0x00000050 6c5f6474 6f72735f 6175785f 66696e69 l_dtors_aux_fini
│    0x00000060 5f617272 61795f65 6e747279 00667261 _array_entry.fra
│    0x00000070 6d655f64 756d6d79 005f5f66 72616d65 me_dummy.__frame
│    0x00000080 5f64756d 6d795f69 6e69745f 61727261 _dummy_init_arra
│ -  0x00000090 795f656e 74727900 74312e61 6b646679 y_entry.t1.akdfy
│ -  0x000000a0 3835392d 6367752e 30005f5a 4e327431 859-cgu.0._ZN2t1
│ -  0x000000b0 346d6169 6e313768 63356436 38623833 4main17hc5d68b83
│ -  0x000000c0 64383164 32343934 45005f5a 4e337374 d81d2494E._ZN3st
│ +  0x00000090 795f656e 74727900 74312e61 79776270 y_entry.t1.aywbp
│ +  0x000000a0 3333742d 6367752e 30005f5a 4e327431 33t-cgu.0._ZN2t1
│ +  0x000000b0 346d6169 6e313768 31386530 34376136 4main17h18e047a6
│ +  0x000000c0 32346637 34613139 45005f5a 4e337374 24f74a19E._ZN3st
│    0x000000d0 64327274 31306c61 6e675f73 74617274 d2rt10lang_start
│    0x000000e0 32385f24 75376224 24753762 24636c6f 28_$u7b$$u7b$clo
│    0x000000f0 73757265 24753764 24247537 64243137 sure$u7d$$u7d$17
│ -  0x00000100 68356434 62633432 31613632 34306162 h5d4bc421a6240ab
│ -  0x00000110 3345005f 5a4e3463 6f726533 6f707338 3E._ZN4core3ops8
│ +  0x00000100 68626462 66636637 34366139 34313030 hbdbfcf746a94100
│ +  0x00000110 6345005f 5a4e3463 6f726533 6f707338 cE._ZN4core3ops8
│    0x00000120 66756e63 74696f6e 36466e4f 6e636534 function6FnOnce4
│    0x00000130 3063616c 6c5f6f6e 63652475 37622424 0call_once$u7b$$
│    0x00000140 75376224 76746162 6c652e73 68696d24 u7b$vtable.shim$
│ -  0x00000150 75376424 24753764 24313768 35383235 u7d$$u7d$17h5825
│ -  0x00000160 32313165 33363561 35656664 45005f5a 211e365a5efdE._Z
│ +  0x00000150 75376424 24753764 24313768 64386334 u7d$$u7d$17hd8c4
│ +  0x00000160 33383634 37313730 34343733 45005f5a 386471704473E._Z
│    0x00000170 4e34636f 72653370 74723138 7265616c N4core3ptr18real
│    0x00000180 5f64726f 705f696e 5f706c61 63653137 _drop_in_place17
│ -  0x00000190 68356539 30623039 37646664 38343531 h5e90b097dfd8451
│ -  0x000001a0 63450034 356f6172 74787a6c 397a7876 cE.45oartxzl9zxv
│ -  0x000001b0 75376100 7374642e 376c7073 766e7262 u7a.std.7lpsvnrb
│ +  0x00000190 68363666 39343337 36633561 33386134 h66f94376c5a38a4
│ +  0x000001a0 61450033 64396e61 76716330 6b323733 aE.3d9navqc0k273
│ +  0x000001b0 6f6c7100 7374642e 376c7073 766e7262 olq.std.7lpsvnrb
│    0x000001c0 2d636775 2e300047 43435f65 78636570 -cgu.0.GCC_excep
│    0x000001d0 745f7461 626c6531 30303000 4743435f t_table1000.GCC_
│    0x000001e0 65786365 70745f74 61626c65 31303032 except_table1002
│    0x000001f0 00474343 5f657863 6570745f 7461626c .GCC_except_tabl
│    0x00000200 65313030 36004743 435f6578 63657074 e1006.GCC_except
│    0x00000210 5f746162 6c653130 32004743 435f6578 _table102.GCC_ex
│    0x00000220 63657074 5f746162 6c653130 33310047 cept_table1031.G

The reason I opened this saying "depend on the source directory location" is that if I do cleanup everything, and do a new build in the same location, the result is identical:

$ cp -r t1 t3
$ cd t1
$ rm -rf target
$ CARGO_INCREMENTAL=0 cargo rustc --release -- --remap-path-prefix=$PWD=. -C codegen-units=1
   Compiling t1 v0.1.0 (/tmp/t1)
    Finished release [optimized] target(s) in 0.31s
$ cd ..
$ diffoscope t[13]/target/release/t1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions