accellera-official / systemc

SystemC Reference Implementation
https://systemc.org/overview/systemc/
Apache License 2.0
451 stars 145 forks source link

Linking SystemC on Windows with MinGW produces Error with QuickThreads #3

Closed myzinsky closed 6 months ago

myzinsky commented 4 years ago
C:\Users\...\systemc\src\sysc\packages\qt\md\iX86_64.s: Assembler messages:
C:\Users\...\systemc\src\sysc\packages\qt\md\iX86_64.s:77: Error: junk at end of line, first unrecognized character is `-'
mingw32-make.exe[2]: *** [...\systemc\src\CMakeFiles\systemc.dir\build.make:1266: .../systemc/src/CMakeFiles/systemc.dir/sysc/packages/qt/md/iX86_64.s.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:1006: .../systemc/src/CMakeFiles/systemc.dir/all] Error 2
mingw32-make.exe: *** [Makefile:129: all] Error 2

SystemC was build with CMAKE in the context of a CMAKE project. Under Linux and macOS its works, but on windows I get this assembler error shown above. It can be fixed by using pthreads but I think qt are much better. 

Any ideas to fix it? 

myzinsky commented 4 years ago

One of my workaround would be to switch to pthreads/fibers. However this code in the CMAKE file prevents me of doing that:

if (WIN32 AND ENABLE_PTHREADS)
  message (FATAL_ERROR "Pthreads is not supported on ${CMAKE_SYSTEM}.")
endif (WIN32 AND ENABLE_PTHREADS)
myzinsky commented 4 years ago

Commenting out the last 3 lines in the .s file helps:

//#if defined(__linux__) && defined(__ELF__)
//.section .note.GNU-stack,"",%progbits
//#endif

I assume that MinGW is still detected as linux

maehne commented 4 years ago

Thanks for reporting this issue and analysing the cause! We are going to look at the issue in the LWG. Could you please try to make the preprocessor condition more strict by adding !defined(__MINGW32__) (see here and here) and report back whether this fixes the issue? If not, please provide more information on your platform (versions of Windows and MinGW, etc.).

maehne commented 3 years ago

User @moayman posted on 2020-07-15 on the SystemC forum about his effort to fix QuickThreads on Win64. He has created a branch containing the current state of his fixes, which is based on SystemC 2.3.2.

mattgately commented 3 years ago

In my CMake build, I was able to fix the issue by overriding some properties before loading the SystemC library:

  if (MINGW)
      set(MSVC true)       # SystemC tries to assemble quick threads if this isn't added
  endif(MINGW)
AmeyaVS commented 3 years ago

Hello @myzinsky and @mattgately ,

What environment are you using for MinGW setup? I faced a similar issue recently and figured out that the issue was with my CMake setup. I am using MSYS2 for managing my MinGW 64-bit environment.

As it seems the environment is split between MSYS2, MinGW 64-bit, MinGW 32-bit. For MSYS2 and MinGWit has separate binaries for CMake which handles the SystemC project quite differently. For reference: cmake packages in MSYS2

In case you are using MSYS2 to manage the setup it is quite easy to fix the issue:

pacman -S mingw64/mingw-w64-x86_64-cmake

Which resolved most of the build issues in the MinGW environment.

Note:

Hope this helps.

eactor commented 7 months ago

I can confirm that it works with MSYS2, using a MINGW64 shell and the correct cmake
pacman -S mingw-w64-x86_64-cmake as already pointed out by @AmeyaVS. (Tested current SystemC 3.0.0) The issue can be closed and could be re-opened if further details about the used cmake and migw system are given.

lmailletcontoz commented 6 months ago

closed; could be re-opened if needed