-
Notifications
You must be signed in to change notification settings - Fork 195
Support for non-CL Clang on Windows #981
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
base: master
Are you sure you want to change the base?
Changes from 13 commits
c7a9a92
2b1f713
51f5332
1607d47
bb6dfe0
6731454
3073f11
deb2196
f08401e
de85fe6
0ccbeae
9529a1b
e311961
833f67a
ebee0ce
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 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -42,6 +42,13 @@ xcheck_add_c_compiler_flag(-Wno-stringop-truncation) | |||||||||||||||||
xcheck_add_c_compiler_flag(-Wno-array-bounds) | ||||||||||||||||||
xcheck_add_c_compiler_flag(-funsigned-char) | ||||||||||||||||||
|
||||||||||||||||||
# Clang on Windows without MSVC command line fails because the codebase uses | ||||||||||||||||||
# functions like strcpy over strcpy_s | ||||||||||||||||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND WIN32) | ||||||||||||||||||
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. Don't you also want to add NOT MSVC here, so make sure it's not ClangCL ? |
||||||||||||||||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS) | ||||||||||||||||||
add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE) | ||||||||||||||||||
endif() | ||||||||||||||||||
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.
Suggested change
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. this did not seem to be there or working if the branch was current yesterday. I had to manual #define and also "#pragma warning(disable : 4996)" in several files for MS Clang to compile. 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. forget my comment ... I upgraded and compile now with msbuild and the problem is fixed. |
||||||||||||||||||
|
||||||||||||||||||
# ClangCL is command line compatible with MSVC, so 'MSVC' is set. | ||||||||||||||||||
if(MSVC) | ||||||||||||||||||
xcheck_add_c_compiler_flag(-Wno-unsafe-buffer-usage) | ||||||||||||||||||
|
@@ -77,7 +84,7 @@ endif() | |||||||||||||||||
if(WIN32) | ||||||||||||||||||
if(MSVC) | ||||||||||||||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:8388608") | ||||||||||||||||||
else() | ||||||||||||||||||
elseif(MINGW) | ||||||||||||||||||
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. Why do you want to skip this on Clang? 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. Clang didn't seem to understand the parameter syntax and I couldn't find an equivalent option. Can take another look 👍 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. --stack_size 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 was wrong. --stack_size is clang on mac. there's no stack size in MS version and I don't think there is in linux. What it does do is ignore the flag --stack_size and not --stack, and I get 140 warnings and don't see it. |
||||||||||||||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,8388608") | ||||||||||||||||||
endif() | ||||||||||||||||||
endif() | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,8 @@ | |
#include <stdarg.h> | ||
#include <stdio.h> | ||
#include <windows.h> | ||
/* Required for JS_PRINTF_FORMAT */ | ||
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. Can we not do this and silence the warnings if need be? I actually want to get rid of this header altogether by parsing command line arguments by hand in qjsc, since it's only used there... |
||
#include "cutils.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
|
@@ -145,7 +147,7 @@ static const char illoptchar[] = "unknown option -- %c"; | |
static const char illoptstring[] = "unknown option -- %s"; | ||
|
||
static void | ||
_vwarnx(const char *fmt,va_list ap) | ||
JS_PRINTF_FORMAT_ATTR(1, 0) _vwarnx(JS_PRINTF_FORMAT const char *fmt,va_list ap) | ||
{ | ||
(void)fprintf(stderr,"%s: ",__progname); | ||
if (fmt != NULL) | ||
|
@@ -154,7 +156,7 @@ _vwarnx(const char *fmt,va_list ap) | |
} | ||
|
||
static void | ||
warnx(const char *fmt,...) | ||
JS_PRINTF_FORMAT_ATTR(1, 2) warnx(JS_PRINTF_FORMAT const char *fmt,...) | ||
{ | ||
va_list ap; | ||
va_start(ap,fmt); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,10 +198,10 @@ static void js_set_thread_state(JSRuntime *rt, JSThreadState *ts) | |
js_std_cmd(/*SetOpaque*/1, rt, ts); | ||
} | ||
|
||
#ifdef __GNUC__ | ||
#if defined(__GNUC__) || defined(__clang__) | ||
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. Doesn't clang-on-windows define
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 believe it does too. What are you trying to fix here @HJfod ? 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. |
||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||
#endif // __GNUC__ | ||
#endif // __GNUC__ || __clang__ | ||
static JSValue js_printf_internal(JSContext *ctx, | ||
int argc, JSValueConst *argv, FILE *fp) | ||
{ | ||
|
@@ -417,9 +417,9 @@ static JSValue js_printf_internal(JSContext *ctx, | |
dbuf_free(&dbuf); | ||
return JS_EXCEPTION; | ||
} | ||
#ifdef __GNUC__ | ||
#if defined(__GNUC__) || defined(__clang__) | ||
#pragma GCC diagnostic pop // ignored "-Wformat-nonliteral" | ||
#endif // __GNUC__ | ||
#endif // __GNUC__ || __clang__ | ||
|
||
uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename) | ||
{ | ||
|
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.
Nit, can we call this windows-real-clang perhaps?