Opened 3 years ago

Closed 3 years ago

#6179 closed defect (fixed)

Improve clang compilation on Windows

Reported by: casella Owned by: adrpo
Priority: blocker Milestone: 1.17.0
Component: Code Generation Version:
Keywords: Cc:

Description

I just tried clang compilation on Windows and it is way faster than th old gcc. This is a major usability improvement.

There are some glitches to fix yet. If you compile, e.g., Modelica.Blocks.Examples.PID_Controller, you get the following error messages in red:

C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(eh_alloc.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(eh_exception.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(eh_personality.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(new_op.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(new_op.o): duplicate section `.rdata$_ZTSSt9bad_alloc[_ZTSSt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(new_op.o): duplicate section `.rdata$_ZTISt9bad_alloc[_ZTISt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(vterminate.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(locale.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(locale_init.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(functexcept.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(functexcept.o): duplicate section `.rdata$_ZTSSt9bad_alloc[_ZTSSt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(functexcept.o): duplicate section `.rdata$_ZTISt9bad_alloc[_ZTISt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(bad_alloc.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(bad_alloc.o): duplicate section `.rdata$_ZTSSt9bad_alloc[_ZTSSt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(bad_alloc.o): duplicate section `.rdata$_ZTISt9bad_alloc[_ZTISt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(bad_cast.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(bad_typeid.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(eh_aux_runtime.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(eh_aux_runtime.o): duplicate section `.rdata$_ZTSSt9bad_alloc[_ZTSSt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(eh_aux_runtime.o): duplicate section `.rdata$_ZTISt9bad_alloc[_ZTISt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(guard.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(stdexcept.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(cxx11-ios_failure.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(system_error.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(bad_array_new.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(bad_array_new.o): duplicate section `.rdata$_ZTSSt9bad_alloc[_ZTSSt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(bad_array_new.o): duplicate section `.rdata$_ZTISt9bad_alloc[_ZTISt9bad_alloc]' has different size
C:\PROGRA~1\OPENMO~2.0-D\tools\msys\mingw64\lib\gcc\x86_64-w64-mingw32\10.2.0\libstdc++.a(ios_failure.o): duplicate section `.rdata$_ZTSSt9exception[_ZTSSt9exception]' has different size

Change History (6)

comment:1 Changed 3 years ago by casella

Looks like clang is trying to link gcc libraries.

comment:2 Changed 3 years ago by adrpo

I will see if I can find a solution for this. But this is not even a warning is just a notification of some kind.

comment:3 Changed 3 years ago by adrpo

Ok. I know how to fix it. Basically we need to link with -lstdc++ dynamically.
The static linking is what gives the notifications.

I guess is again the discussion on which one to use.
We need an OMC/OMEdit setting as we have for FMI to
build dynamic or static simulation executables.

Very fast link for dynamic ones but you will need to copy dlls and the model files with your exe, slow for static linking but the .exe and the model files are all that is needed.

comment:4 Changed 3 years ago by casella

OK, some comments

  1. If those are not even warnings, they shouldn't be displayed in red
  2. Regarding static vs. dynamic linking of stdc++, I agree we may need both.
  3. For normal OMEdit simulation, we should favour compilation speed -> dynamic.
  4. In case you want use the simulation executable outside OMEdit, having a self-contained .exe file without dependencies is a lot better.
  5. I guess a compilation flag is required. I would probably make static default, to have a safe default behaviour, and then have OMEdit set the flag for dynamic linking.

comment:5 Changed 3 years ago by adrpo

Should be fixed by: https://github.com/OpenModelica/OpenModelica/pull/7017
but now the simulation executable will need libstdc++-6.dll to run.

I hope this will be fixed in the gcc linker ld in msys2 in the future as the problem seems to be there, see the discussion here:
https://github.com/msys2/MINGW-packages/issues/6855#issuecomment-680859662
Basically clang/llvm generates different sizes than gcc for the same things inside the object files.

comment:6 Changed 3 years ago by adrpo

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.