Jump to content
RDP1974

question about GPL and Delphi

Recommended Posts

hello,

 

I want to use GPL sources into a closed source Delphi app,

I cannot made the Delphi app under GPL because I use commercial components.

 

Now:

1) if I link the objects $L from C GPL code, then I'm obliged to open and make all Delphi code GPL?

2) if I link a DLL from C GPL code, again here I need to open to GPL?

3) if I do a EXE from GPL code, then my closed code is Delphi and I use the first EXE with as a bridge with RPC or shared memory IPC dialogue; if so can I solve the problem of using GPL inside a commercial Delphi code?

 

Thanks

Share this post


Link to post
Posted (edited)

Contrary to popular belief, the GPL does not require you to open source your code. You must only give the source to everybody who you give the binaries. But you must not place any restrictions on how that source code can be used by these people / companies. So: It's absolutely OK to use GPL code for internally used programs, as long as these programs stay within the company. (But try to explain that to management...)

 

But if you sell your program or make it available in any other way, you will have to include the source code, not just of your own code but also of all components, which obviously is not possible, unless these components are also open source with a GPL compatible license.

 

Btw: You don't have to put that source code under the GPL, you only need to make it available without any restrictions. So anybody else can use it, even in a GPL program.

 

This applies for statically linking the source code, a lib / obj file or even a DLL.

 

If I remember correctly it does not apply if your program can load a DLL on demand for some special functionality. In that case you might get away with including only some of your source code that is used for that special functionality.

 

It does not apply at all if you call an external executable. There are no restrictions in that case.

Edited by dummzeuch

Share this post


Link to post

If your program requires the covered code in order to function then I think your code needs to also be GPL. Worth talking to the developer of the code. Often they will dual license for such eventualities. 

Share this post


Link to post

Yes, GPL is known as a "viral licence": it infects with freedom any program using its source.

 

Note there is a difference between GPL 2 and GPL 3 - the later being a bit more precise, and explicit about patent issues.

https://www.ifross.org/en/what-difference-between-gplv2-and-gplv3

 

And that a library could also be published under LGPL, which is a version with "linking exception".

Share this post


Link to post
On 8/1/2020 at 9:58 AM, Arnaud Bouchez said:

Yes, GPL is known as a "viral licence": it infects with freedom any program using its source.

 

Note there is a difference between GPL 2 and GPL 3 - the later being a bit more precise, and explicit about patent issues.

https://www.ifross.org/en/what-difference-between-gplv2-and-gplv3

 

And that a library could also be published under LGPL, which is a version with "linking exception".

Hi Arnaud,

 

can I port your FPC mem manager under Delphi (Windows)?

I'll translate AVX to Delphi ASM.

 

But, I need your permission of course.

 

Let me know.

 

Roberto

Share this post


Link to post

@RDP1974

Yes, we may make it Delphi compatible.

The only big difference with FastMM4 is the lock-less round-robin of tiny blocks, and a diverse repartition.

Also the locking strategies are not the same than FastMM4.

Then some micro-optimization during the refactoring.

We will see how it works with Delphi Win64.

Share this post


Link to post

To translate AVX-2 opcodes to Delphi we should use a object disassembler? And put hexadecimal DB values directly? Or translate by hand using intel manual and a calculator :-)

 

Do you know if exists a similar tool as https://torry.net/files/vcl/experts/other/mmxasm.zip for AVX?

Share this post


Link to post

For object disassembler i suggest objconv from https://www.agner.org/optimize/ 

Use it like this

Quote

objconv -fmasm pcre32_byte_order.obj

it does different assembler (masm, fasm, yasm, gasm) but you will prefer masm as it is the closest to Delphi assembler, the difference is small.

 

But you don't need the assembly itself you need the machine code bytes, if i get this right, the output of the above is like this

; Disassembly of file: pcre32_byte_order.obj
; Wed Aug  5 19:22:10 2020
; Type: COFF32
; Syntax: MASM/ML
; Instruction set: Pentium Pro

; Error: symbol names contain illegal characters,
; 2 Symbol names not changed

.686
option dotname
.model flat

public _pcre32_pattern_to_host_byte_order

extern __pcre32_OP_lengths: byte

@comp.id equ 010469A1H                                  ; 17066401
@feat.00 equ 80000191H                                  ; -2147483247


.drectve SEGMENT BYTE PUBLIC 'CONST'                    ; section number 1

        db 20H, 20H, 20H, 2FH, 44H, 45H, 46H, 41H       ; 0000 _    /DEFA
        db 55H, 4CH, 54H, 4CH, 49H, 42H, 3AH, 22H       ; 0008 _ ULTLIB:"
        db 4DH, 53H, 56H, 43H, 52H, 54H, 22H, 20H       ; 0010 _ MSVCRT" 
        db 2FH, 44H, 45H, 46H, 41H, 55H, 4CH, 54H       ; 0018 _ /DEFAULT
        db 4CH, 49H, 42H, 3AH, 22H, 4FH, 4CH, 44H       ; 0020 _ LIB:"OLD
        db 4EH, 41H, 4DH, 45H, 53H, 22H, 20H            ; 0028 _ NAMES" 

.drectve ENDS

.text$mn SEGMENT PARA PUBLIC 'CODE'                     ; section number 3
;  Communal section not supported by MASM

_pcre32_pattern_to_host_byte_order PROC NEAR
        push    ebp                                     ; 0000 _ 55
        mov     ebp, esp                                ; 0001 _ 8B. EC
        push    ecx                                     ; 0003 _ 51
        mov     edx, dword ptr [ebp+8H]                 ; 0004 _ 8B. 55, 08
        test    edx, edx                                ; 0007 _ 85. D2
        jnz     ?_001                                   ; 0009 _ 75, 07
        lea     eax, [edx-2H]                           ; 000B _ 8D. 42, FE
        mov     esp, ebp                                ; 000E _ 8B. E5
        pop     ebp                                     ; 0010 _ 5D
        ret                                             ; 0011 _ C3
_pcre32_pattern_to_host_byte_order ENDP

?_001   LABEL NEAR
        mov     eax, dword ptr [edx]                    ; 0012 _ 8B. 02
        cmp     eax, 1346589253                         ; 0014 _ 3D, 50435245		////  <---------  This 
        jnz     ?_002                                   ; 0019 _ 75, 12
        test    byte ptr [edx+0CH], 04H                 ; 001B _ F6. 42, 0C, 04
        jz      ?_004                                   ; 001F _ 74, 27
        mov     eax, dword ptr [ebp+10H]                ; 0021 _ 8B. 45, 10
        mov     dword ptr [edx+30H], eax                ; 0024 _ 89. 42, 30

$LN14   LABEL NEAR
        xor     eax, eax                                ; 0027 _ 33. C0
        mov     esp, ebp                                ; 0029 _ 8B. E5
        pop     ebp                                     ; 002B _ 5D
        ret                                             ; 002C _ C3

?_002:  cmp     eax, 1163019088                         ; 002D _ 3D, 45524350		////  <---------  This 
        jz      ?_003                                   ; 0032 _ 74, 09
        mov     eax, 4294967292                         ; 0034 _ B8, FFFFFFFC		////  <---------  This 
        mov     esp, ebp                                ; 0039 _ 8B. E5
        pop     ebp                                     ; 003B _ 5D
        ret                                             ; 003C _ C3

?_003:  mov     ecx, dword ptr [edx+0CH]                ; 003D _ 8B. 4A, 0C
        test    ecx, 4000000H                           ; 0040 _ F7. C1, 04000000	////  <---------  This 
        jnz     ?_005                                   ; 0046 _ 75, 09
?_004:  mov     eax, 4294967268                         ; 0048 _ B8, FFFFFFE4
        mov     esp, ebp                                ; 004D _ 8B. E5
        pop     ebp                                     ; 004F _ 5D
        ret                                             ; 0050 _ C3

This is small portion of the output to point the most important thing here, you see the code bytes needed ( the bytes in hex after the index per function)

I marked few lines with <--This because those need special care due the big endianness

Quote

; 0040 _ F7. C1, 04000000    ////  <---------  This 

the bytes you need in right order will be

F7 C1 00 00 00 04 

and that will be the rule for any value bigger than one byte, then break it into bytes and revers them

 

But i don't think you want this, as you wrote assembly and you can't just assume it is working fine, means you already made them run on some compiler FPC or VS ... in that case then ditch the object converter and use https://x64dbg.com/ ,the best debugger out there, in the main page there is a screenshot you can see the code bytes and they are reversed already .

x64dbg.thumb.png.dfa8f5e1842e3105136b6558d122c66e.png

Share this post


Link to post

better to wait Embarcadero support for AVX into Delphi asm ... need too much time and easy to do errors

Edited by RDP1974

Share this post


Link to post
16 minutes ago, RDP1974 said:

better to wait Embarcadero support for AVX into Delphi asm ... need too much time and easy to do errors

could be a long wait

Share this post


Link to post

for now I go with a pair of DLL from Intel TBB, IPP for mem manager and fillchar, move, pos avx enhanced

if I do an error into asm conversion will be hard to catch! Too risky 🙂

Share this post


Link to post
2 hours ago, David Heffernan said:

could be a long wait

(I cannot understand why they don't invest in compiler and rtl that's the core value of the whole toolchain ... )

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×