Skip to content

Commit c714185

Browse files
[libc] suppress more clang-cl warnings (#117718)
- migrate more `-O3` to `${libc_opt_high_flag}` - workaround a issue with `LLP64` in test. The overflow testing is guarded by a constexpr but the literal overflow itself will still trigger warnings. Notice that for math smoke test, for some reasons, the `${libc_opt_high_flag}` will be passed into `lld-link` which confuses the linker so there are still some warnings leftover there. I can investigate more when I have time.
1 parent c9562b1 commit c714185

File tree

10 files changed

+28
-27
lines changed

10 files changed

+28
-27
lines changed

libc/src/__support/threads/linux/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ add_object_library(
8888
libc.src.__support.error_or
8989
libc.src.__support.threads.thread_common
9090
COMPILE_OPTIONS
91-
-O3
91+
${libc_opt_high_flag}
9292
-fno-omit-frame-pointer # This allows us to sniff out the thread args from
9393
# the new thread's stack reliably.
9494
-Wno-frame-address # Yes, calling __builtin_return_address with a

libc/src/complex/generic/CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ add_entrypoint_object(
55
HDRS
66
../creal.h
77
COMPILE_OPTIONS
8-
-O3
8+
${libc_opt_high_flag}
99
DEPENDS
1010
libc.src.__support.CPP.bit
1111
libc.src.__support.complex_type
@@ -18,7 +18,7 @@ add_entrypoint_object(
1818
HDRS
1919
../crealf.h
2020
COMPILE_OPTIONS
21-
-O3
21+
${libc_opt_high_flag}
2222
DEPENDS
2323
libc.src.__support.CPP.bit
2424
libc.src.__support.complex_type
@@ -31,7 +31,7 @@ add_entrypoint_object(
3131
HDRS
3232
../creall.h
3333
COMPILE_OPTIONS
34-
-O3
34+
${libc_opt_high_flag}
3535
DEPENDS
3636
libc.src.__support.CPP.bit
3737
libc.src.__support.complex_type
@@ -44,7 +44,7 @@ add_entrypoint_object(
4444
HDRS
4545
../crealf16.h
4646
COMPILE_OPTIONS
47-
-O3
47+
${libc_opt_high_flag}
4848
DEPENDS
4949
libc.src.__support.CPP.bit
5050
libc.src.__support.complex_type
@@ -59,7 +59,7 @@ add_entrypoint_object(
5959
HDRS
6060
../crealf128.h
6161
COMPILE_OPTIONS
62-
-O3
62+
${libc_opt_high_flag}
6363
DEPENDS
6464
libc.src.__support.CPP.bit
6565
libc.src.__support.complex_type
@@ -74,7 +74,7 @@ add_entrypoint_object(
7474
HDRS
7575
../cimag.h
7676
COMPILE_OPTIONS
77-
-O3
77+
${libc_opt_high_flag}
7878
DEPENDS
7979
libc.src.__support.CPP.bit
8080
libc.src.__support.complex_type
@@ -87,7 +87,7 @@ add_entrypoint_object(
8787
HDRS
8888
../cimagf.h
8989
COMPILE_OPTIONS
90-
-O3
90+
${libc_opt_high_flag}
9191
DEPENDS
9292
libc.src.__support.CPP.bit
9393
libc.src.__support.complex_type
@@ -100,7 +100,7 @@ add_entrypoint_object(
100100
HDRS
101101
../cimagl.h
102102
COMPILE_OPTIONS
103-
-O3
103+
${libc_opt_high_flag}
104104
DEPENDS
105105
libc.src.__support.CPP.bit
106106
libc.src.__support.complex_type
@@ -113,7 +113,7 @@ add_entrypoint_object(
113113
HDRS
114114
../cimagf16.h
115115
COMPILE_OPTIONS
116-
-O3
116+
${libc_opt_high_flag}
117117
DEPENDS
118118
libc.src.__support.CPP.bit
119119
libc.src.__support.complex_type
@@ -128,7 +128,7 @@ add_entrypoint_object(
128128
HDRS
129129
../cimagf128.h
130130
COMPILE_OPTIONS
131-
-O3
131+
${libc_opt_high_flag}
132132
DEPENDS
133133
libc.src.__support.CPP.bit
134134
libc.src.__support.complex_type

libc/src/pthread/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ add_entrypoint_object(
333333
libc.src.pthread.pthread_attr_getstack
334334
libc.src.errno.errno
335335
COMPILE_OPTIONS
336-
-O3
336+
${libc_opt_high_flag}
337337
-fno-omit-frame-pointer
338338
)
339339

libc/src/setjmp/riscv/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ add_entrypoint_object(
77
DEPENDS
88
libc.hdr.types.jmp_buf
99
COMPILE_OPTIONS
10-
-O3
10+
${libc_opt_high_flag}
1111
-fomit-frame-pointer
1212
)
1313

@@ -20,6 +20,6 @@ add_entrypoint_object(
2020
DEPENDS
2121
libc.hdr.types.jmp_buf
2222
COMPILE_OPTIONS
23-
-O3
23+
${libc_opt_high_flag}
2424
-fomit-frame-pointer
2525
)

libc/src/setjmp/x86_64/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ add_entrypoint_object(
77
DEPENDS
88
libc.hdr.types.jmp_buf
99
COMPILE_OPTIONS
10-
-O3
10+
${libc_opt_high_flag}
1111
)
1212

1313
add_entrypoint_object(
@@ -19,6 +19,6 @@ add_entrypoint_object(
1919
DEPENDS
2020
libc.hdr.types.jmp_buf
2121
COMPILE_OPTIONS
22-
-O3
22+
${libc_opt_high_flag}
2323
-fomit-frame-pointer
2424
)

libc/src/signal/linux/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ add_object_library(
4141
__restore.cpp
4242
COMPILE_OPTIONS
4343
-fomit-frame-pointer
44-
-O3
44+
${libc_opt_high_flag}
4545
-Wframe-larger-than=0
4646
-Wno-attributes
4747
# asan creates asan.module_ctor which uses stack space, causing warnings.

libc/src/stdfix/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ foreach(suffix IN ITEMS hr r lr hk k lk)
1010
SRCS
1111
abs${suffix}.cpp
1212
COMPILE_OPTIONS
13-
-O3
13+
${libc_opt_high_flag}
1414
DEPENDS
1515
libc.src.__support.fixed_point.fx_bits
1616
)
@@ -24,7 +24,7 @@ foreach(suffix IN ITEMS uhr ur ulr uhk uk)
2424
SRCS
2525
sqrt${suffix}.cpp
2626
COMPILE_OPTIONS
27-
-O3
27+
${libc_opt_high_flag}
2828
DEPENDS
2929
libc.src.__support.fixed_point.sqrt
3030
)
@@ -38,7 +38,7 @@ foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk)
3838
SRCS
3939
round${suffix}.cpp
4040
COMPILE_OPTIONS
41-
-O3
41+
${libc_opt_high_flag}
4242
DEPENDS
4343
libc.src.__support.fixed_point.fx_bits
4444
)
@@ -62,7 +62,7 @@ add_entrypoint_object(
6262
SRCS
6363
uhksqrtus.cpp
6464
COMPILE_OPTIONS
65-
-O3
65+
${libc_opt_high_flag}
6666
DEPENDS
6767
libc.src.__support.fixed_point.sqrt
6868
)
@@ -74,7 +74,7 @@ add_entrypoint_object(
7474
SRCS
7575
uksqrtui.cpp
7676
COMPILE_OPTIONS
77-
-O3
77+
${libc_opt_high_flag}
7878
DEPENDS
7979
libc.src.__support.fixed_point.sqrt
8080
)
@@ -86,7 +86,7 @@ add_entrypoint_object(
8686
SRCS
8787
exphk.cpp
8888
COMPILE_OPTIONS
89-
-O3
89+
${libc_opt_high_flag}
9090
DEPENDS
9191
libc.src.__support.fixed_point.fx_rep
9292
libc.src.__support.CPP.bit
@@ -99,7 +99,7 @@ add_entrypoint_object(
9999
SRCS
100100
expk.cpp
101101
COMPILE_OPTIONS
102-
-O3
102+
${libc_opt_high_flag}
103103
DEPENDS
104104
libc.src.__support.fixed_point.fx_rep
105105
libc.src.__support.CPP.bit

libc/src/string/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ function(add_implementation name impl_name)
506506
SRCS ${ADD_IMPL_SRCS}
507507
HDRS ${ADD_IMPL_HDRS}
508508
DEPENDS ${ADD_IMPL_DEPENDS}
509-
COMPILE_OPTIONS -O3 ${ADD_IMPL_COMPILE_OPTIONS}
509+
COMPILE_OPTIONS ${libc_opt_high_flag} ${ADD_IMPL_COMPILE_OPTIONS}
510510
)
511511
get_fq_target_name(${impl_name} fq_target_name)
512512
set_target_properties(${fq_target_name} PROPERTIES REQUIRE_CPU_FEATURES "${ADD_IMPL_REQUIRE}")

libc/src/threads/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ add_entrypoint_object(
2424
libc.include.threads
2525
libc.src.errno.errno
2626
COMPILE_OPTIONS
27-
-O3
27+
${libc_opt_high_flag}
2828
-fno-omit-frame-pointer # This allows us to sniff out the thread args from
2929
# the new thread's stack reliably.
3030
)

libc/test/src/math/smoke/LdExpTest.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class LdExpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
5050

5151
if constexpr (sizeof(U) < sizeof(long) || sizeof(long) == sizeof(int))
5252
return;
53-
long long_exp_array[4] = {LONG_MIN, INT_MIN - 1L, INT_MAX + 1L, LONG_MAX};
53+
long long_exp_array[4] = {LONG_MIN, static_cast<long>(INT_MIN - 1LL),
54+
static_cast<long>(INT_MAX + 1LL), LONG_MAX};
5455
for (long exp : long_exp_array) {
5556
ASSERT_FP_EQ(zero, func(zero, exp));
5657
ASSERT_FP_EQ(neg_zero, func(neg_zero, exp));

0 commit comments

Comments
 (0)