Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@idavis
Copy link
Contributor

@idavis idavis commented Nov 4, 2021

To aid in consumption of the QIR Runtime, most configuration has been moved into the CMakeLists.txt.

@idavis idavis requested review from kuzminrobin and swernli November 4, 2021 13:43
Copy link
Collaborator

@swernli swernli left a comment

Choose a reason for hiding this comment

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

This looks good to me! One question below on the UBSan.ignore file and how that might be moved into the CMakeLists.txt too. But as is I think this is a good change to make!

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")

if (NOT WIN32)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=unsigned-integer-overflow -fsanitize=implicit-conversion -fsanitize=local-bounds -fsanitize=nullability")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: Is there a reason to not just combine this and the lines below into a single long string with newlines? Something like:

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} \
  -fsanitize=undefined \
  -fsanitize=float-divide-by-zero \
 ...
")

# https://releases.llvm.org/11.0.1/tools/clang/docs/SanitizerSpecialCaseList.html
$sanitizeFlags = " -fsanitize-blacklist=" # https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#suppressing-errors-in-recompiled-code-ignorelist
# https://releases.llvm.org/11.0.1/tools/clang/docs/SanitizerSpecialCaseList.html
$sanitizeFlags += (Join-Path $Path .. UBSan.ignore)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is not having this flag in the CMakeLists.txt going to interfere with the sanitizer behavior when compiling directly through there? Would it be worth putting this path into a define variable that is then used in the CMakeLists.txt?

Comment on lines -176 to +59
if (($IsMacOS) -or ((Test-Path Env:/AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Darwin"))))
{
if (($IsMacOS) -or ((Test-Path Env:/AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Darwin")))) {
Copy link
Contributor

@kuzminrobin kuzminrobin Nov 4, 2021

Choose a reason for hiding this comment

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

I would recommend to do the unrelated changes like this one in a separate small preparatory PR.

The current PR has certain logic relocation. And it takes some time to double-check that the correctness of the logic is preserved. The multiple small unrelated changes like this one complicate the analysis of the correctness.

Is also applicable to the lines that change the number of spaces.

Copy link
Contributor

@kuzminrobin kuzminrobin left a comment

Choose a reason for hiding this comment

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

I'm done with the CR pass.
I would recommend to preserve the sanitizer comments. Other notes are up to you.

@idavis
Copy link
Contributor Author

idavis commented Nov 4, 2021

@kuzminrobin @swernli Thanks for taking a look. I left the flags separate rather than consolidate as I was unsure as to which way to go with the comments. It sounds like the preferred path is to migrate the comments into the CMakeLists.txt to preserve more historical knowledge. I'll rework and push. Thanks for your help.

Copy link
Contributor

@kuzminrobin kuzminrobin left a comment

Choose a reason for hiding this comment

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

LGTM. Approving.
I would consider handling WARNING_FLAGS before the SANITIZE_FLAGS.
Also the fragment

# Always use available Spectre mitigations where available
if (NOT APPLE)
    set(WARNING_FLAGS "${WARNING_FLAGS} -mspeculative-load-hardening -mretpoline")
endif()

does not seem applicable to warnings. So you might want to use a different var instead of WARNING_FLAGS.
Up to you.

@kuzminrobin
Copy link
Contributor

LGTM, re-approving.

@idavis
Copy link
Contributor Author

idavis commented Nov 4, 2021

@kuzminrobin Nice catch on the Spectre mitigations. Pushed what you requested.

@idavis idavis merged commit 9239c42 into main Nov 5, 2021
@idavis idavis deleted the iadavis/qir-runtime-cmake branch November 5, 2021 00:15
idavis added a commit that referenced this pull request Nov 5, 2021
* Moving QIR runtime build config into qir_cmake_include  CMakeLists.
cesarzc added a commit that referenced this pull request Nov 5, 2021
* Use explicit static VC runtime on Windows (#851)

* Use explicit static VC runtime on Windows

This change updates the QIR runtime to use an explicit path to the Spectre-mitigated, static VC runtime on Windows. Using a full path here overrides the selection logic and ensures the chosen libcmt[d] and vcruntime[d] are loaded.

* Add "-sort" flag

* Include version number in find pattern

* Include libcpmt library as well

* Use spectre component name

* Append AppId to UserAgent when calling Azure Quantum APIs (#858)

* Add `CX`, `CY` and `CZ` to Type1, Type3 target packages. (#842) (#861)

* Moving QIR runtime build config into CMakeLists. (#863)

* Moving QIR runtime build config into qir_cmake_include  CMakeLists.

Co-authored-by: Stefan J. Wernli <[email protected]>
Co-authored-by: XField <[email protected]>
Co-authored-by: Ian Davis <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants