HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.2k stars 657 forks source link

[hl] Possible t$fun_ naming clashes in HL/C #9022

Open kaikoga opened 4 years ago

kaikoga commented 4 years ago
$ gcc -O3 -o main_heaps -std=c11 -I . main_heaps.c -lhl
In file included from main_heaps.c:786:
./hl/types.c:6763:9: error: redefinition of 't$fun_844d5e9'
hl_type t$fun_844d5e9 = { HFUN } /* (arpx.texture.Texture,virtual(toString:method:():String,keys:method:():virtual(hasNext:method:():bool,next:method:()...
        ^
./hl/types.c:6542:9: note: previous definition is here
hl_type t$fun_844d5e9 = { HFUN } /* (arpx.screen.Screen,virtual(readUtf:method:(String):String,readUInt32:method:(String):i32,readScope:method:(String,(...
        ^
./hl/types.c:21372:17: error: redefinition of 'fargst$fun_844d5e9'
static hl_type *fargst$fun_844d5e9[] = {&t$arpx_texture_Texture,&t$vrt_a254827,&t$arpx_impl_heaps_geom_RectImpl};
                ^
./hl/types.c:20928:17: note: previous definition is here
static hl_type *fargst$fun_844d5e9[] = {&t$arpx_screen_Screen,&t$vrt_4567b5e};
                ^
2 errors generated.
$

I've tried to port my existing Heaps project to HL/C, but was unlucky enough to have naming clash in output C source code.

I have 6881 occurences of hl_type t$fun_ in my 7.2MB hl/types.c.

The project can be normally built and run with HL/JIT (or JS and Flash).

Aurel300 commented 4 years ago

Congratulations, you won the birthday lottery!

6881 functions, 28-bit hashes – ~8.4% chance of a collision.

ncannasse commented 4 years ago

I guess we should do full [a-z0-9] range (maybe not A-Z as we don't want to have two results with only case insensitive differences) , this should give 36 bits which is much more reasonable.

nadako commented 3 years ago

I'm trying to make hl/c tests running on CI and this issue prevents compilation (among others i have yet to figure out). Please fix :)