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

stl/CMakeLists.txt: Fix add_compile_options() ordering #3402

Merged
merged 2 commits into from
Feb 14, 2023

Conversation

StephanTLavavej
Copy link
Member

Our ASM_MASM options were being ignored (!) because they appeared after add_library(). This was visible in the output because /nologo was missing, we just didn't notice. (See output below.) This regression happened in #2780.

To fix this and prevent any recurrence, I'm slightly reorganizing this file. First, I'm introducing 3 prominent box comments, dividing the file into clear sections. The actual fix is to move add_compile_options() up. Finally, I'm moving add_compile_definitions() down slightly, so that the compile definitions, compile options, and include directories are grouped together.

I've additionally verified the fix by looking at the verbose build output; our desired options are now being passed to MASM.

Before

D:\GitHub\STL>ninja -C out\x64
ninja: Entering directory `out\x64'
[1/1014] Building ASM_MASM object stl\CMakeFiles\stl_alias_objects.dir\src\alias_init_once_begin_initialize.asm.obj
Microsoft (R) Macro Assembler (x64) Version 14.35.32213.0
Copyright (C) Microsoft Corporation.  All rights reserved.

 Assembling: D:\GitHub\STL\stl\src\alias_init_once_begin_initialize.asm
[2/1014] Building ASM_MASM object stl\CMakeFiles\stl_alias_objects.dir\src\alias_init_once_complete.asm.obj
Microsoft (R) Macro Assembler (x64) Version 14.35.32213.0
Copyright (C) Microsoft Corporation.  All rights reserved.

 Assembling: D:\GitHub\STL\stl\src\alias_init_once_complete.asm
[1014/1014] Linking CXX static library out\lib\amd64\libcpmtd0.lib

After

D:\GitHub\STL>ninja -C out\x64
ninja: Entering directory `out\x64'
[1/1014] Building ASM_MASM object stl\CMakeFiles\stl_alias_objects.dir\src\alias_init_once_complete.asm.obj
 Assembling: D:\GitHub\STL\stl\src\alias_init_once_complete.asm
[2/1014] Building ASM_MASM object stl\CMakeFiles\stl_alias_objects.dir\src\alias_init_once_begin_initialize.asm.obj
 Assembling: D:\GitHub\STL\stl\src\alias_init_once_begin_initialize.asm
[1014/1014] Linking CXX static library out\lib\amd64\libcpmtd0.lib

Note

I've implemented a /quiet option for MASM in VS 2022 17.7 Preview 1 that will allow the "Assembling" messages to be suppressed, making the output here ideal - that's how I discovered this.

Our ASM_MASM options were being ignored (!) because they appeared
after add_library(). This was visible in the output because /nologo
was missing, we just didn't notice.

To fix this and prevent any recurrence, I'm slightly reorganizing this
file. First, I'm introducing 3 prominent box comments, dividing the
file into clear sections. The actual fix is to move
add_compile_options() up. Finally, I'm moving add_compile_definitions()
down slightly, so that the compile definitions, compile options, and
include directories are grouped together.
@StephanTLavavej StephanTLavavej added bug Something isn't working build Related to the build system labels Feb 11, 2023
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner February 11, 2023 01:08
Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes! Approve once suggestions are complete.

stl/CMakeLists.txt Outdated Show resolved Hide resolved
@StephanTLavavej StephanTLavavej self-assigned this Feb 13, 2023
@StephanTLavavej
Copy link
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 932e11b into microsoft:main Feb 14, 2023
@StephanTLavavej StephanTLavavej deleted the cmake-ordering branch February 14, 2023 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Related to the build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants