Page MenuHomePhabricator

clang-cl: Remove -O0 option
ClosedPublic

Authored by thakis on Jul 10 2019, 9:12 AM.

Details

Summary

cl.exe doesn't understand it; there's /Od instead. See also the review
thread for r229575.

Update lots of compiler-rt tests to use -Od instead of -O0.
Ran rg -l 'clang_cl.*O0' compiler-rt/test/ | xargs sed -i -c 's/-O0/-Od/'

Diff Detail

Repository
rL LLVM

Event Timeline

thakis created this revision.Jul 10 2019, 9:12 AM

I did check that we now warn, like you had requested:

$ out/gn/bin/clang-cl test.cc /O0 /c
clang: warning: argument unused during compilation: '/O0' [-Wunused-command-line-argument]

Adding a test for that felt weird though, so I didn't.

rnk added a comment.Jul 10 2019, 1:48 PM

Does clang-cl -O0 without a / still work, though? It's used:

$ git grep O0 ../compiler-rt/test/asan/TestCases/Windows/
../compiler-rt/test/asan/TestCases/Windows/aligned_mallocs.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/allocators_sanity.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/beginthreadex.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/bitfield.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/bitfield_uaf.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
...

In D64506#1579251, @rnk wrote:

Does clang-cl -O0 without a / still work, though? It's used:

$ git grep O0 ../compiler-rt/test/asan/TestCases/Windows/
../compiler-rt/test/asan/TestCases/Windows/aligned_mallocs.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/allocators_sanity.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/beginthreadex.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/bitfield.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/bitfield_uaf.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cc:// RUN: %clang_cl_asan -O0 %s -Fe%t
...

Oh thanks, I only ran clang tests, not compiler-rt tests.

It no longer works, O isn't a CoreOption:

$ out/gn/bin/clang-cl test.cc -O0 /c
clang: warning: argument unused during compilation: '-O0' [-Wunused-command-line-argument]

But these tests should just use /Od, right?

update tests

(not yet executed, don't have a win machine today)

Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2019, 4:18 PM
thakis edited the summary of this revision. (Show Details)Jul 10 2019, 4:18 PM
thakis edited the summary of this revision. (Show Details)
rnk accepted this revision.Jul 10 2019, 5:19 PM

lgtm

This revision is now accepted and ready to land.Jul 10 2019, 5:19 PM
Closed by commit rL365724: clang-cl: Remove -O0 option (authored by nico, committed by ). · Explain WhyJul 10 2019, 6:19 PM
This revision was automatically updated to reflect the committed changes.