Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add llvm-mingw build support #62

Merged
merged 4 commits into from Apr 10, 2022
Merged

Conversation

alvinhochun
Copy link
Contributor

@alvinhochun alvinhochun commented Apr 8, 2022

Add support to build using the llvm-mingw toolchain: https://github.com/mstorsjo/llvm-mingw

The test test_mgwhelp_zdebug needs to be disabled because the toolchain wasn't built with LLVM_ENABLE_ZLIB. Other than that, all tests are passing.

(Outdated information below:)

Quite some tests are failing:

Test project D:/dev/krita/drmingw/b
    Start 1: test_mgwhelp
1/8 Test #1: test_mgwhelp .....................***Failed    0.03 sec
    Start 2: test_mgwhelp_split
2/8 Test #2: test_mgwhelp_split ...............***Failed    0.03 sec
    Start 3: test_mgwhelp_split_subdir
3/8 Test #3: test_mgwhelp_split_subdir ........***Failed    0.03 sec
    Start 4: test_mgwhelp_stripped
4/8 Test #4: test_mgwhelp_stripped ............   Passed    0.03 sec
    Start 5: test_mgwhelp_zdebug
5/8 Test #5: test_mgwhelp_zdebug ..............***Not Run (Disabled)   0.00 sec
    Start 6: test_exchndl_static
6/8 Test #6: test_exchndl_static ..............***Failed    0.05 sec
    Start 7: test_exchndl_dynamic
7/8 Test #7: test_exchndl_dynamic .............***Failed    0.05 sec
    Start 8: test_addr2line
8/8 Test #8: test_addr2line ...................   Passed    0.86 sec

29% tests passed, 5 tests failed out of 7
Test log
Start testing: Apr 08 17:59 ??�Xe?D�PCRE?!
----------------------------------------------------------
1/8 Testing: test_mgwhelp
1/8 Test: test_mgwhelp
Command: "D:/dev/krita/drmingw/b/bin/test_mgwhelp.exe"
Directory: D:/dev/krita/drmingw/b/tests
"test_mgwhelp" start time: Apr 08 17:59 ??�Xe?D�PCRE?!
Output:
----------------------------------------------------------
ok 1 - GetProcAddress("SymGetOptions")
ok 2 - !GetProcAddress("SymGetOptions")
ok 3 - SymInitialize()
ok 4 - SymFromAddr(&foo)
ok 5 - SymFromAddr(&foo).Name
not ok 6 - SymGetLineFromAddr64(&foo)
# Attempt to access invalid address.

ok 7 - SymFromAddr(&main)
ok 8 - SymFromAddr(&main).Name
not ok 9 - SymGetLineFromAddr64(&main)
# Attempt to access invalid address.

ok 10 - SymFromAddr(&Sleep)
ok 11 - SymFromAddr(&Sleep).Name
ok 12 - SymCleanup()
1..12
<end of output>
Test time =   0.03 sec
----------------------------------------------------------
Test Failed.
"test_mgwhelp" end time: Apr 08 17:59 ??�Xe?D�PCRE?!
"test_mgwhelp" time elapsed: 00:00:00
----------------------------------------------------------

2/8 Testing: test_mgwhelp_split
2/8 Test: test_mgwhelp_split
Command: "D:/dev/krita/drmingw/b/bin/test_mgwhelp_split.exe"
Directory: D:/dev/krita/drmingw/b/tests
"test_mgwhelp_split" start time: Apr 08 17:59 ??�Xe?D�PCRE?!
Output:
----------------------------------------------------------
ok 1 - GetProcAddress("SymGetOptions")
ok 2 - !GetProcAddress("SymGetOptions")
ok 3 - SymInitialize()
not ok 4 - SymFromAddr(&foo)
# Attempt to access invalid address.

not ok 5 - SymGetLineFromAddr64(&foo)
# Attempt to access invalid address.

not ok 6 - SymFromAddr(&main)
# Attempt to access invalid address.

not ok 7 - SymGetLineFromAddr64(&main)
# Attempt to access invalid address.

ok 8 - SymFromAddr(&Sleep)
ok 9 - SymFromAddr(&Sleep).Name
ok 10 - SymCleanup()
1..10
<end of output>
Test time =   0.03 sec
----------------------------------------------------------
Test Failed.
"test_mgwhelp_split" end time: Apr 08 17:59 ??�Xe?D�PCRE?!
"test_mgwhelp_split" time elapsed: 00:00:00
----------------------------------------------------------

3/8 Testing: test_mgwhelp_split_subdir
3/8 Test: test_mgwhelp_split_subdir
Command: "D:/dev/krita/drmingw/b/bin/test_mgwhelp_split_subdir.exe"
Directory: D:/dev/krita/drmingw/b/tests
"test_mgwhelp_split_subdir" start time: Apr 08 17:59 ??�Xe?D�PCRE?!
Output:
----------------------------------------------------------
ok 1 - GetProcAddress("SymGetOptions")
ok 2 - !GetProcAddress("SymGetOptions")
ok 3 - SymInitialize()
not ok 4 - SymFromAddr(&foo)
# Attempt to access invalid address.

not ok 5 - SymGetLineFromAddr64(&foo)
# Attempt to access invalid address.

not ok 6 - SymFromAddr(&main)
# Attempt to access invalid address.

not ok 7 - SymGetLineFromAddr64(&main)
# Attempt to access invalid address.

ok 8 - SymFromAddr(&Sleep)
ok 9 - SymFromAddr(&Sleep).Name
ok 10 - SymCleanup()
1..10
<end of output>
Test time =   0.03 sec
----------------------------------------------------------
Test Failed.
"test_mgwhelp_split_subdir" end time: Apr 08 17:59 ??�Xe?D�PCRE?!
"test_mgwhelp_split_subdir" time elapsed: 00:00:00
----------------------------------------------------------

4/8 Testing: test_mgwhelp_stripped
4/8 Test: test_mgwhelp_stripped
Command: "D:/dev/krita/drmingw/b/bin/test_mgwhelp_stripped.exe"
Directory: D:/dev/krita/drmingw/b/tests
"test_mgwhelp_stripped" start time: Apr 08 17:59 ??�Xe?D�PCRE?!
Output:
----------------------------------------------------------
ok 1 - GetProcAddress("SymGetOptions")
ok 2 - !GetProcAddress("SymGetOptions")
ok 3 - SymInitialize()
ok 4 - SymFromAddr(&foo)
ok 5 - SymFromAddr(&foo).Name
ok 6 - SymFromAddr(&main)
ok 7 - SymFromAddr(&main).Name
ok 8 - SymFromAddr(&Sleep)
ok 9 - SymFromAddr(&Sleep).Name
ok 10 - SymCleanup()
1..10
<end of output>
Test time =   0.03 sec
----------------------------------------------------------
Test Passed.
"test_mgwhelp_stripped" end time: Apr 08 17:59 ??�Xe?D�PCRE?!
"test_mgwhelp_stripped" time elapsed: 00:00:00
----------------------------------------------------------

5/8 Testing: test_mgwhelp_zdebug
5/8 Test: test_mgwhelp_zdebug
Command: ""
Directory: D:/dev/krita/drmingw/b/tests
"test_mgwhelp_zdebug" start time: 
Output:
----------------------------------------------------------
<end of output>
Test time =   0.00 sec
----------------------------------------------------------
Test Passed.
"test_mgwhelp_zdebug" end time: Apr 08 17:59 ??�Xe?D�PCRE?!
"test_mgwhelp_zdebug" time elapsed: 00:00:00
----------------------------------------------------------

6/8 Testing: test_exchndl_static
6/8 Test: test_exchndl_static
Command: "D:/dev/krita/drmingw/b/bin/test_exchndl_static.exe"
Directory: D:/dev/krita/drmingw/b/bin
"test_exchndl_static" start time: Apr 08 17:59 ??�Xe?D�PCRE?!
Output:
----------------------------------------------------------
ok 1 - ExcHndlSetLogFileNameA("test_exchndl_static.RPT")
ok 2 - longjmp
ok 3 - fopen("test_exchndl_static.RPT")
ok 4 - strstr(" caused an Access Violation ")
ok 5 - strstr(" Writing to location 0000000000000000")
not ok 6 - strstr(" test_exchndl_static.exe!main ")
not ok 7 - strstr("test_exchndl.h @ 125]")
-------------------

Error occurred on Friday, April 8, 2022 at 17:59:07.

test_exchndl_static.exe caused an Access Violation at location 00007FF6E989158E in module test_exchndl_static.exe Writing to location 0000000000000000.

AddrPC           Params
00007FF6E989158E 0000000000000000 00007FF6E9897668 0000000000000000  test_exchndl_static.exe!main
00007FF6E98913D7 0000000000000000 0000000000000000 0000000000000000  test_exchndl_static.exe!__tmainCRTStartup
00007FF6E9891436 0000000000000000 0000000000000000 0000000000000000  test_exchndl_static.exe!mainCRTStartup
00007FFAA3037034 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FFAA4DA2651 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart

00007FF6E9890000-00007FF6E98AC000 test_exchndl_static.exe
00007FFAA4D50000-00007FFAA4F45000 ntdll.dll   	6.2.19041.1288
00007FFAA3020000-00007FFAA30DE000 KERNEL32.DLL	6.2.19041.1348
00007FFAA24F0000-00007FFAA27B8000 KERNELBASE.dll	6.2.19041.1387
00007FFAA45D0000-00007FFAA4625000 SHLWAPI.dll 	6.2.19041.1023
00007FFAA44C0000-00007FFAA455E000 msvcrt.dll  	7.0.19041.546
00007FFAA2B80000-00007FFAA2C80000 ucrtbase.dll	6.2.19041.789
00007FFA62D90000-00007FFA62E52000 exchndl.dll 	0.9.4.0
00007FFAA38A0000-00007FFAA394C000 ADVAPI32.dll	6.2.19041.1052
00007FFAA4760000-00007FFAA4768000 PSAPI.DLL   	6.2.19041.546
00007FFAA33E0000-00007FFAA347B000 sechost.dll 	6.2.19041.1415
00007FFAA3950000-00007FFAA4094000 SHELL32.dll 	6.2.19041.1387
00007FFAA32B0000-00007FFAA33DA000 RPCRT4.dll  	6.2.19041.1288
00007FFA58420000-00007FFA586D3000 mgwhelp.dll 	0.9.4.0
00007FFAA29D0000-00007FFAA2A6D000 msvcp_win.dll	6.2.19041.789
00007FFA9B110000-00007FFA9B11A000 VERSION.dll 	6.2.19041.546
00007FFAA4310000-00007FFAA44B1000 USER32.dll  	6.2.19041.1202
00007FFAA2A70000-00007FFAA2A92000 win32u.dll  	6.2.19041.1387
00007FFAA2FF0000-00007FFAA301B000 GDI32.dll   	6.2.19041.1202
00007FFA55370000-00007FFA55563000 dbghelp.dll 	10.0.17763.1
00007FFAA2C80000-00007FFAA2D8D000 gdi32full.dll	6.2.19041.1387
00007FFA77B30000-00007FFA77B5A000 dbgcore.DLL 	10.0.17763.1
00007FFAA1E00000-00007FFAA1E18000 CRYPTSP.dll 	6.2.19041.546
00007FFAA1520000-00007FFAA1554000 rsaenh.dll  	6.2.19041.1052
00007FFAA2B00000-00007FFAA2B27000 bcrypt.dll  	6.2.19041.1023
00007FFAA1E20000-00007FFAA1E2C000 CRYPTBASE.dll	6.2.19041.546
00007FFAA2460000-00007FFAA24E2000 bcryptPrimitives.dll	6.2.19041.1415
00007FFAA41E0000-00007FFAA4210000 IMM32.DLL   	6.2.19041.546
00007FFAA0510000-00007FFAA0CA4000 windows.storage.dll	6.2.19041.1387
00007FFAA3480000-00007FFAA37D5000 combase.dll 	6.2.19041.1348
00007FFAA1EB0000-00007FFAA1EDE000 Wldp.dll    	6.2.19041.1320
00007FFAA2D90000-00007FFAA2E3D000 SHCORE.dll  	6.2.19041.1387
00007FFA64A70000-00007FFA64ADC000 symsrv.dll  	10.0.17763.1
00007FFAA4560000-00007FFAA45CB000 WS2_32.dll  	6.2.19041.546
00007FFAA27C0000-00007FFAA2916000 CRYPT32.dll 	6.2.19041.1320

Windows 6.2.9200
DrMingw 0.9.4

1..7
<end of output>
Test time =   0.05 sec
----------------------------------------------------------
Test Failed.
"test_exchndl_static" end time: Apr 08 17:59 ??�Xe?D�PCRE?!
"test_exchndl_static" time elapsed: 00:00:00
----------------------------------------------------------

7/8 Testing: test_exchndl_dynamic
7/8 Test: test_exchndl_dynamic
Command: "D:/dev/krita/drmingw/b/bin/test_exchndl_dynamic.exe"
Directory: D:/dev/krita/drmingw/b/bin
"test_exchndl_dynamic" start time: Apr 08 17:59 ??�Xe?D�PCRE?!
Output:
----------------------------------------------------------
ok 1 - LoadLibraryA("exchndl.dll")
ok 2 - !GetProcAddress("ExcHndlSetLogFileNameA@4")
ok 3 - GetProcAddress("ExcHndlSetLogFileNameA")
ok 4 - ExcHndlSetLogFileNameA("test_exchndl_dynamic.RPT")
ok 5 - longjmp
ok 6 - fopen("test_exchndl_dynamic.RPT")
ok 7 - strstr(" caused an Access Violation ")
ok 8 - strstr(" Writing to location 0000000000000000")
not ok 9 - strstr(" test_exchndl_dynamic.exe!main ")
not ok 10 - strstr("test_exchndl.h @ 125]")
-------------------

Error occurred on Friday, April 8, 2022 at 17:59:07.

test_exchndl_dynamic.exe caused an Access Violation at location 00007FF7D81D1667 in module test_exchndl_dynamic.exe Writing to location 0000000000000000.

AddrPC           Params
00007FF7D81D1667 0000000000000000 00007FF7D81D7668 0000000000000000  test_exchndl_dynamic.exe!main
00007FF7D81D13D7 0000000000000000 0000000000000000 0000000000000000  test_exchndl_dynamic.exe!__tmainCRTStartup
00007FF7D81D1436 0000000000000000 0000000000000000 0000000000000000  test_exchndl_dynamic.exe!mainCRTStartup
00007FFAA3037034 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FFAA4DA2651 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart

00007FF7D81D0000-00007FF7D81EC000 test_exchndl_dynamic.exe
00007FFAA4D50000-00007FFAA4F45000 ntdll.dll   	6.2.19041.1288
00007FFAA3020000-00007FFAA30DE000 KERNEL32.DLL	6.2.19041.1348
00007FFAA24F0000-00007FFAA27B8000 KERNELBASE.dll	6.2.19041.1387
00007FFAA45D0000-00007FFAA4625000 SHLWAPI.dll 	6.2.19041.1023
00007FFAA44C0000-00007FFAA455E000 msvcrt.dll  	7.0.19041.546
00007FFAA2B80000-00007FFAA2C80000 ucrtbase.dll	6.2.19041.789
00007FFAA38A0000-00007FFAA394C000 ADVAPI32.dll	6.2.19041.1052
00007FFAA33E0000-00007FFAA347B000 sechost.dll 	6.2.19041.1415
00007FFAA32B0000-00007FFAA33DA000 RPCRT4.dll  	6.2.19041.1288
00007FFAA1E00000-00007FFAA1E18000 CRYPTSP.dll 	6.2.19041.546
00007FFAA1520000-00007FFAA1554000 rsaenh.dll  	6.2.19041.1052
00007FFAA2B00000-00007FFAA2B27000 bcrypt.dll  	6.2.19041.1023
00007FFAA1E20000-00007FFAA1E2C000 CRYPTBASE.dll	6.2.19041.546
00007FFAA2460000-00007FFAA24E2000 bcryptPrimitives.dll	6.2.19041.1415
00007FFA62D90000-00007FFA62E52000 exchndl.dll 	0.9.4.0
00007FFAA4760000-00007FFAA4768000 PSAPI.DLL   	6.2.19041.546
00007FFAA3950000-00007FFAA4094000 SHELL32.dll 	6.2.19041.1387
00007FFA58420000-00007FFA586D3000 mgwhelp.dll 	0.9.4.0
00007FFAA29D0000-00007FFAA2A6D000 msvcp_win.dll	6.2.19041.789
00007FFA9B110000-00007FFA9B11A000 VERSION.dll 	6.2.19041.546
00007FFAA4310000-00007FFAA44B1000 USER32.dll  	6.2.19041.1202
00007FFA55370000-00007FFA55563000 dbghelp.dll 	10.0.17763.1
00007FFAA2A70000-00007FFAA2A92000 win32u.dll  	6.2.19041.1387
00007FFAA2FF0000-00007FFAA301B000 GDI32.dll   	6.2.19041.1202
00007FFA77B30000-00007FFA77B5A000 dbgcore.DLL 	10.0.17763.1
00007FFAA2C80000-00007FFAA2D8D000 gdi32full.dll	6.2.19041.1387
00007FFAA41E0000-00007FFAA4210000 IMM32.DLL   	6.2.19041.546
00007FFAA0510000-00007FFAA0CA4000 windows.storage.dll	6.2.19041.1387
00007FFAA3480000-00007FFAA37D5000 combase.dll 	6.2.19041.1348
00007FFAA1EB0000-00007FFAA1EDE000 Wldp.dll    	6.2.19041.1320
00007FFAA2D90000-00007FFAA2E3D000 SHCORE.dll  	6.2.19041.1387
00007FFA64A70000-00007FFA64ADC000 symsrv.dll  	10.0.17763.1
00007FFAA4560000-00007FFAA45CB000 WS2_32.dll  	6.2.19041.546
00007FFAA27C0000-00007FFAA2916000 CRYPT32.dll 	6.2.19041.1320

Windows 6.2.9200
DrMingw 0.9.4

1..10
<end of output>
Test time =   0.05 sec
----------------------------------------------------------
Test Failed.
"test_exchndl_dynamic" end time: Apr 08 17:59 ??�Xe?D�PCRE?!
"test_exchndl_dynamic" time elapsed: 00:00:00
----------------------------------------------------------

8/8 Testing: test_addr2line
8/8 Test: test_addr2line
Command: "D:/dev/krita/drmingw/b/bin/test_addr2line.exe"
Directory: D:/dev/krita/drmingw/b/bin
"test_addr2line" start time: Apr 08 17:59 ??�Xe?D�PCRE?!
Output:
----------------------------------------------------------
ok 1 - _popen("addr2line.exe -e D:/dev/krita/drmingw/b/bin/test_addr2line.exe -f 0x1620")
_ZL3Foov

??:?

ok 2 - strstr("Foo")
1..2
<end of output>
Test time =   0.86 sec
----------------------------------------------------------
Test Passed.
"test_addr2line" end time: Apr 08 17:59 ??�Xe?D�PCRE?!
"test_addr2line" time elapsed: 00:00:00
----------------------------------------------------------

End testing: Apr 08 17:59 ??�Xe?D�PCRE?!

@alvinhochun
Copy link
Contributor Author

alvinhochun commented Apr 8, 2022

Ah right, it's probably because of #42 (comment) I guess?

Update: Yes, adding -gdwarf-aranges does make the tests pass.

@jrfonseca
Copy link
Owner

Please rebase onto 7ca13c9 to avoid build-cross apt failure.

@alvinhochun alvinhochun marked this pull request as draft April 8, 2022 13:02
@alvinhochun alvinhochun marked this pull request as ready for review April 8, 2022 14:15
@alvinhochun
Copy link
Contributor Author

The failed check with mingw64 seems to be a race condition but not caused by my changes.

@jrfonseca
Copy link
Owner

Looks good.

Like I said before, I'm not keen on supporting building DrMinGW with many different toolchains, but I'll make an exception here, as the changes are relatively small.

It will be good to add llvm-mingw to github actions. If not to build the whole DrMinGW then at least to build test/apps, to ensure apps built with llvm-mingw work well with DrMinGW.

@jrfonseca jrfonseca merged commit 29e9d57 into jrfonseca:master Apr 10, 2022
@alvinhochun
Copy link
Contributor Author

It will be good to add llvm-mingw to github actions. If not to build the whole DrMinGW then at least to build test/apps, to ensure apps built with llvm-mingw work well with DrMinGW.

I might make a PR in the future. I experimented with that already (see https://github.com/alvinhochun/drmingw/runs/5889330187?check_suite_focus=true), but there are failures with tests calling abort() -- they exit with 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN) instead of 3, which seems to be a difference with ucrt (retail version) vs the old msvcrt. I haven't looked into the possible ways to fix them cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants