Bug: cannot compile on Linux - when local types has same name lazarus / 62-General ---------------------------------------------------------------------- ydd · 2021-04-30 14:56 simple code example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; interface type  TCompileTest1 = class  type    T = (t1);  const    S1: array[T] of String = ('t1');  end;   TCompileTest2 = class  type    T = (t2);  const    S2: array[T] of String = ('t2');  end; implementation end. Compile log: QuoteCompile Project, Target: project1: Exit code 1, Errors: 2, Hints: 2 Hint: Start of reading config file /home/yd/Lazarus/trunk_210430/fpc/bin/x86_64-linux/fpc.cfg Hint: End of reading config file /home/yd/Lazarus/trunk_210430/fpc/bin/x86_64-linux/fpc.cfg Verbose: Free Pascal Compiler version 3.3.1-r49298 [2021/04/30] for x86_64 Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others Verbose: Target OS: Linux for x86-64 Verbose: Compiling project1.lpr Verbose: Compiling unit1.pas Error: Asm: Duplicate label DBG_$UNIT1_$$_T Error: Asm: Duplicate label DBGREF_$UNIT1_$$_T Verbose: There were 2 errors compiling module, stopping Verbose: Compilation aborted Verbose: /home/yd/Lazarus/trunk_210430/fpc/bin/x86_64-linux/ppcx64 returned an error exitcode on Windows I can compile without errors ---------------------------------------------------------------------- Bart · 2021-04-30 16:03 You must have different versions of the compiler on Windows vs Linux then. Bart ---------------------------------------------------------------------- howardpc · 2021-04-30 16:12 It may be a bug on Windows to allow two distinct types to have the same name. I think at least {$mode objfpc} disallows this. But your unit has no mode specified, so presumably it takes the default mode. Nor is it clear whether the compiler should generate shortstrings or some other string type. ---------------------------------------------------------------------- ydd · 2021-04-30 22:55 Quote from: Bart on April 30, 2021, 06:03:20 pmYou must have different versions of the compiler on Windows vs Linux then I use latest trunk on both ---------------------------------------------------------------------- ydd · 2021-04-30 22:57 Quote from: howardpc on April 30, 2021, 06:12:49 pmIt may be a bug on Windows to allow two distinct types to have the same name. I think at least {$mode objfpc} disallows this. But your unit has no mode specified, so presumably it takes the default mode. it is valid Pascal code, and it works everywhere else - Delphi, FPC for Windows & MacOS. {$mode objfpc} - does not matter. Problem that in generated by compiler ASM code there are duplicate lines: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i .globl  DBG_$UNIT1_$$_T ---------------------------------------------------------------------- ydd · 2021-05-04 13:26 I believe that it is bug in compiler for Linux. Is it ok to create bug report? How? ---------------------------------------------------------------------- ccrause · 2021-05-04 14:46 Quote from: ydd on May 04, 2021, 03:26:36 pmI believe that it is bug in compiler for Linux. Is it ok to create bug report? How? Create an account: https://bugs.freepascal.org/signup_page.php Log an issue: https://bugs.freepascal.org/bug_report_page.php ---------------------------------------------------------------------- Aistis · 2025-10-30 08:13 This seems to still be an issue 4 years later. Excerpt from my code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TLayerLockOrVisChange = class(THistoryStep)type  TType = (stVisibility, stLock);private<...>public<...>end; TLayerAddRemoveChange = class(THistoryStep)type  TType = (stAddLayer, stRemoveLayer);private<...>public<...>end;                 Local types with the same name compile on Windows with FPC 3.2.2 but throws errors on Linux with FPC 3.2.2 QuoteError: Asm: Duplicate label DBG_$DRAWHISTORY_$$_TTYPE Error: Asm: Duplicate label DBGREF_$DRAWHISTORY_$$_TTYPE ---------------------------------------------------------------------- cdbc · 2025-10-30 08:24 Hi These are not local:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TLayerLockOrVisChange = class(THistoryStep)type  TType = (stVisibility, stLock);private<...>public<...>end; TLayerAddRemoveChange = class(THistoryStep)privatetype  TType = (stAddLayer, stRemoveLayer);<...>public<...>end;                 Whereas these are:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TLayerLockOrVisChange = class(THistoryStep)privatetype  TType = (stVisibility, stLock);<...>public<...>end; TLayerAddRemoveChange = class(THistoryStep)privatetype  TType = (stAddLayer, stRemoveLayer);<...>public<...>end;                 by convention, stuff in a section /without/ visibility-modifier are 'public/published(M+)'. Regards Benny ---------------------------------------------------------------------- Aistis · 2025-10-30 08:34 Quote from: cdbc on October 30, 2025, 09:24:23 amHi These are not local:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TLayerLockOrVisChange = class(THistoryStep)type  TType = (stVisibility, stLock);private<...>public<...>end; TLayerAddRemoveChange = class(THistoryStep)privatetype  TType = (stAddLayer, stRemoveLayer);<...>public<...>end;                 Whereas these are:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TLayerLockOrVisChange = class(THistoryStep)privatetype  TType = (stVisibility, stLock);<...>public<...>end; TLayerAddRemoveChange = class(THistoryStep)privatetype  TType = (stAddLayer, stRemoveLayer);<...>public<...>end;                 by convention, stuff in a section /without/ visibility-modifier are 'public/published(M+)'. Regards Benny The type definition is local on Windows but global on Linux? I access it through TDrawHistory.TLayerLockOrVisChange.TType (Unit.Class.Type) on Windows while Linux seems to treat it as it was a TDrawHistory.TType (Unit.Type) despite the type being defined inside a class. I don't quite understand what you're getting at. ---------------------------------------------------------------------- Martin_fr · 2025-10-30 08:37 QuoteCode: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Error: Asm: Duplicate label DBG_$UNIT1_$$_TError: Asm: Duplicate label DBGREF_$UNIT1_$$_T I have sometimes seen similar errors, but with missing labels. However, the important detail here is that it refers to DBG => debug. This is likely a label involved in the generation of debug info (probably DWARF). The error I have seen (and its possible it applies here too) happen if DWARF versions are mixed across different files (usually different packages / including the RTL as a package). That is if any part of the used units is compiled with DWARF 2 and any other units have DWARF 3 (or DWARF 4), then label generation goes wrong. And that is Linux only (not sure MAC). On Windows those labels don't exist, as the linking of debug info differs, and so the compiler has to write them a little different. Check all your included units, with what debug info they were build (including RTL, and FPC-packages if used) ---------------------------------------------------------------------- Martin_fr · 2025-10-30 08:43 Quote from: Aistis on October 30, 2025, 09:13:53 amLocal types with the same name compile on Windows with FPC 3.2.2 but throws errors on Linux with FPC 3.2.2 QuoteError: Asm: Duplicate label DBG_$DRAWHISTORY_$$_TTYPE Error: Asm: Duplicate label DBGREF_$DRAWHISTORY_$$_TTYPE Not sure if that is "different dwarf versions" ... (But still, check it) Are those types used across different units? Does the error happen if they only appear (declaration and usage) in a single unit? It's debug info, and dwarf cross unit differs between Windows and Linux. - On Windows, a copy is written for each unit. (But possible (I don't know) that contains a "fix" avoiding the duplicate) - On Linux, references cross unit are done. Not sure how that would lead to a duplicate. But essentially, the fact that the implementation differs explains the "one OS, but not the other". ---------------------------------------------------------------------- Thaddy · 2025-10-30 08:49 Are you all awake and reading? QuoteFree Pascal Compiler version 3.3.1-r49298 [2021/04/30] for x86_64Your trunk dates from before the git era and your code example simply compiles in trunk for both windows and linux with a trunk from 2025/10/26. debug or release mode. It is a bit silly to have such an old trunk version... It borders on being a criminal act. I can't imagine nobody spotted that. ---------------------------------------------------------------------- Aistis · 2025-10-30 08:54 Quote from: Martin_fr on October 30, 2025, 09:43:02 amQuote from: Aistis on October 30, 2025, 09:13:53 amLocal types with the same name compile on Windows with FPC 3.2.2 but throws errors on Linux with FPC 3.2.2 QuoteError: Asm: Duplicate label DBG_$DRAWHISTORY_$$_TTYPE Error: Asm: Duplicate label DBGREF_$DRAWHISTORY_$$_TTYPE Not sure if that is "different dwarf versions" ... (But still, check it) Are those types used across different units? Does the error happen if they only appear (declaration and usage) in a single unit? It's debug info, and dwarf cross unit differs between Windows and Linux. - On Windows, a copy is written for each unit. (But possible (I don't know) that contains a "fix" avoiding the duplicate) - On Linux, references cross unit are done. Not sure how that would lead to a duplicate. But essentially, the fact that the implementation differs explains the "one OS, but not the other". I tried a clean debug build with Dwarf 2, Dwarf 2 with sets, and Dwarf 3 Beta (Lazarus 4.2 FPC 3.2.2) and they all throw the same error. The release build, however, compiles without issues. So it's a Dwarf issue it seems. ---------------------------------------------------------------------- Thaddy · 2025-10-30 08:57 For that to work, you need trunk/main where the compiler allows it. And a recent trunk, not from 2021 ---------------------------------------------------------------------- Aistis · 2025-10-30 09:40 Quote from: Thaddy on October 30, 2025, 09:57:46 amFor that to work, you need trunk/main where the compiler allows it. And a recent trunk, not from 2021 Sorry, Thaddy, but I hijacked this old thread. The original author was on 2021 trunk, I'm on what's currently available to download and install from lazarus-ide.org. ---------------------------------------------------------------------- Thaddy · 2025-10-30 10:36 Currentlu avaliable is the sourcecode from which you can build trunk. You can also use fpcupdeluxe for that. Your code works in both linux and windows nowadays. It won't work with fpc 3.2.2 or 3.2.3 or 3.2.4RC1 Also, it is not a bug but a new feature.