bmx-ng / bcc

A next-generation bcc parser for BlitzMax
zlib License
33 stars 12 forks source link

x86-stdcall support of shared libs - Aliases removed #544

Open GWRon opened 3 years ago

GWRon commented 3 years ago

When compiling shared libraries (DLL files) in the "stdcall" version - so like this:

Function MyFunc:Int() export "Win32"
End Function

The generated .def file only contains

LIBRARY testdll
EXPORTS
    MyFunc@0

But it used to be

LIBRARY testdll
EXPORTS
    MyFunc

    MyFunc@0 = MyFunc

This happens since the commit https://github.com/bmx-ng/bcc/commit/d2be2db1981058680a32cfd3710463e209072e12

The merge removed a part of the method TransDef in ctranslator.bmx: current:

    Method TransDef(app:TAppDecl)

        SetOutput("def")

        Emit "LIBRARY " + StripExt(StripDir(opt_filepath))
        Emit "EXPORTS"

        For Local decl:TFuncDecl=EachIn app.exportDefs
            Emit "~t" + TransExportDef(decl, opt_arch = "x86")
        Next

        Emit "~n"
    End Method

Before:

    Method TransDef(app:TAppDecl)

        SetOutput("def")

        Emit "LIBRARY " + StripExt(StripDir(opt_filepath))
        Emit "EXPORTS"

        For Local decl:TFuncDecl=EachIn app.exportDefs
            Emit "~t" + TransExportDef(decl, False)
        Next

        If opt_arch = "x86" Then
            Emit "~n"

            For Local decl:TFuncDecl=EachIn app.exportDefs
                If decl.attrs & DECL_API_STDCALL Then
                    Emit "~t" + TransExportDef(decl, True) + " = " + TransExportDef(decl, False)
                End If
            Next
        End If

        Emit "~n"
    End Method
GWRon commented 3 years ago

Updated as the "diff" at github was a bit misleading but manual diffing revealed that there was a real commit doing exactly this removal.

Is there a reason for having it removed?

How to build 32bit DLLs which do export "Win32" - does the dll-using application have to use the "@" style when referencing the dll functions?

As the question was asked by some discord-channel-users I will quote explanations and replies of here to there.

woollybah commented 3 years ago

Maybe because it wasn't working properly?

GWRon commented 3 years ago

Maybe - so what would be needed to make it work properly?

Talking about x86 DLL files with export "Win32" and without the "@argumentsize" when importing the functions inside the actual app - or is this not possible (if this is the case - just mention it and close the issue)?