-
Notifications
You must be signed in to change notification settings - Fork 145
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
fix build on mingw #446
base: master
Are you sure you want to change the base?
fix build on mingw #446
Changes from 7 commits
765a6da
37f4785
88679c0
2f615c0
2189000
be31c45
c1bd5cd
8783407
410660f
d911291
ff4d2b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -125,8 +125,10 @@ IF (OPENSSL_FOUND AND NOT (OPENSSL_VERSION VERSION_LESS "1.0.1")) | |||||||||||||||||||||||||||||||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) | ||||||||||||||||||||||||||||||||
ADD_LIBRARY(picotls-openssl lib/openssl.c) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(picotls-openssl ${OPENSSL_CRYPTO_LIBRARIES} picotls-core ${CMAKE_DL_LIBS}) | ||||||||||||||||||||||||||||||||
ADD_EXECUTABLE(cli t/cli.c lib/pembase64.c) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(cli picotls-openssl picotls-core) | ||||||||||||||||||||||||||||||||
IF (NOT WIN32) | ||||||||||||||||||||||||||||||||
ADD_EXECUTABLE(cli t/cli.c lib/pembase64.c) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(cli picotls-openssl picotls-core) | ||||||||||||||||||||||||||||||||
ENDIF () | ||||||||||||||||||||||||||||||||
ADD_EXECUTABLE(picotls-esni src/esni.c) | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure why you need to exclude "pembase64.c" on Windows builds. It works well with the direct Windows port, with one caveat: you have to define the preprocessor flag "_WINDOWS". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. t/cli is not possible to build on Visual Studio. Lines 27 to 41 in 7e97d3e
|
||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(picotls-esni picotls-openssl picotls-core ${OPENSSL_CRYPTO_LIBRARIES} ${CMAKE_DL_LIBS}) | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
@@ -180,17 +182,30 @@ IF (NOT WITH_FUSION) | |||||||||||||||||||||||||||||||
SET_TARGET_PROPERTIES(ptlsbench PROPERTIES EXCLUDE_FROM_ALL 1) | ||||||||||||||||||||||||||||||||
ENDIF () | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
ADD_CUSTOM_TARGET(check env BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove --exec '' -v ${CMAKE_CURRENT_BINARY_DIR}/*.t t/*.t WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${TEST_EXES} cli) | ||||||||||||||||||||||||||||||||
IF (NOT WIN32) | ||||||||||||||||||||||||||||||||
ADD_CUSTOM_TARGET(check env BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove --exec '' -v ${CMAKE_CURRENT_BINARY_DIR}/*.t t/*.t WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${TEST_EXES} cli) | ||||||||||||||||||||||||||||||||
ENDIF () | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
IF (CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||||||||||||||||||||||||||||||||
SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -pthread ${CMAKE_C_FLAGS}") | ||||||||||||||||||||||||||||||||
ELSEIF ("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS") | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(cli "socket" "nsl") | ||||||||||||||||||||||||||||||||
ENDIF () | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
FIND_LIBRARY(LIBC_RESOLV_LIB "resolv") | ||||||||||||||||||||||||||||||||
IF (OPENSSL_FOUND AND LIBC_RESOLV_LIB) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(cli ${LIBC_RESOLV_LIB}) | ||||||||||||||||||||||||||||||||
IF (NOT WIN32) | ||||||||||||||||||||||||||||||||
FIND_LIBRARY(LIBC_RESOLV_LIB "resolv") | ||||||||||||||||||||||||||||||||
IF (OPENSSL_FOUND AND LIBC_RESOLV_LIB) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(cli ${LIBC_RESOLV_LIB}) | ||||||||||||||||||||||||||||||||
ENDIF () | ||||||||||||||||||||||||||||||||
ENDIF () | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
IF (WIN32) | ||||||||||||||||||||||||||||||||
INCLUDE_DIRECTORIES(picotlsvs/picotls) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(test-minicrypto.t bcrypt ws2_32) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(test-openssl.t bcrypt ws2_32) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(test-fusion.t bcrypt ws2_32) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(ptlsbench bcrypt ws2_32) | ||||||||||||||||||||||||||||||||
TARGET_LINK_LIBRARIES(picotls-esni ws2_32) | ||||||||||||||||||||||||||||||||
ENDIF () | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
IF (BUILD_FUZZER) | ||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
#include <stdint.h> | ||
#include <stddef.h> | ||
|
||
#ifdef _WINDOWS | ||
#ifdef _WIN32 | ||
#include <intrin.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not change this code, that would break the native Visual Studio implementation. If you really prefer using the string "_WIN32", then you could write: #if defined(_WIN32) || defined(_WINDOWS) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to define _WINDOWS since _WIN32 is always set on Windows. (even if Windows 64 bit) |
||
#endif | ||
|
||
|
@@ -298,7 +298,7 @@ static inline void copy_bytes_unaligned(uint8_t *out, const uint8_t *in, size_t | |
|
||
static inline uint32_t count_trailing_zeroes(uint32_t x) | ||
{ | ||
#ifdef _WINDOWS | ||
#ifdef _WIN32 | ||
uint32_t r = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same remark as above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I replaced all _WINDOWS to _WIN32 since _WINDOWS is not required for mingw and Visual Studio both. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am dubious about this because the CI checks are not running after your changes in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason the ci didn't run after this change is because I merged this change from another branch. https://github.com/mattn/picotls/actions @kazuho could you please re-run the action for latest changes ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mattn Mind pushing an empty commit? I think @huitema is wondering if we could rerun CI on appveyor. Regarding Official documentation does state that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it is not something that Visual Studio sets. It is something that I kind of invented 5 years ago as I was trying to make things work. I think that to be complete, we should also edit the Visual Studio projects that use the _WINDOWS and _WINDOWS64 macros. But I could do that in a different PR. As soon as I see a correct test run, I will approve the changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK, _WIN32 can be used for checking Windows OS from 12 years ago at least. For example, I used _WIN32 in 2010 that works with both compilers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mattn I do realize that I made a mistake 5 years ago. As I said, I just need to see the test run... |
||
_BitScanReverse(&r, x); | ||
return (31 - r); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name "windows" is a bit confusing, as we also have a direct port on Windows relying on Visual Studio. Maybe use "mingw" for clarity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this change broke the CI tests -- they did not run at all after that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current implementation of t/cli.c have many UNIX-ish codes. So we can not run it. But this can be useful to check build error for future's changes at least.