RDP1974 40 Posted July 31, 2020 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
dummzeuch 1505 Posted July 31, 2020 (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 July 31, 2020 by dummzeuch Share this post Link to post
David Heffernan 2345 Posted July 31, 2020 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
Vincent Parrett 750 Posted July 31, 2020 https://www.gnu.org/licenses/gpl-faq.en.html Share this post Link to post
Arnaud Bouchez 407 Posted August 1, 2020 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
RDP1974 40 Posted August 1, 2020 What happens when a GPL code violates a patent? Share this post Link to post
RDP1974 40 Posted August 2, 2020 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
Arnaud Bouchez 407 Posted August 4, 2020 @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
RDP1974 40 Posted August 5, 2020 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
Guest Posted August 5, 2020 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 . Share this post Link to post
RDP1974 40 Posted August 6, 2020 (edited) better to wait Embarcadero support for AVX into Delphi asm ... need too much time and easy to do errors Edited August 6, 2020 by RDP1974 Share this post Link to post
David Heffernan 2345 Posted August 6, 2020 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
RDP1974 40 Posted August 6, 2020 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
RDP1974 40 Posted August 6, 2020 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
RDP1974 40 Posted August 15, 2020 meantime I did a real test on FastMM5 -> under webbroker standalone webserver, running apachebench ab -n 10000 -c 100 -k -r http://192.168.1.150:8080/ -> FastMM5 executable is faster identical at Intel TBB (both 11k reqs/sec) but with a benchmark TParallel.For I get -> - Parallel For used : 1030549 ticks / BlockThreadContentionCounts: 0/2327401/0 ThreadContention testing reported critical areas - consider to increse the corresponding CFastMM_XXXXXBlockArenaCount constant - with TBB Parallel For used : 202024 ticks (5 times quicker on I9 8/16 core) in a single thread benchmark poker game -> 2M with TBB 2650k with FMM4 2750k with FMM5 so actually for single thread apps FMM5 wins by a few margin over FMM4 but for multithread should be tuned? I forward this post to the author of FMM. Share this post Link to post
Mahdi Safsafi 225 Posted August 15, 2020 On 8/6/2020 at 4:11 PM, RDP1974 said: (I cannot understand why they don't invest in compiler and rtl that's the core value of the whole toolchain ... ) I guess there is so little developers are currently interested about assembly. Use nasm(its very well maintained) to assemble your code and then use gdb/ndisasm to get the opcodes. Also, worth checking FPC (if I remember correctly, it already supports avx). Share this post Link to post