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

Fix/clang10 linux #12837

Merged
merged 1 commit into from
Aug 17, 2020
Merged

Fix/clang10 linux #12837

merged 1 commit into from
Aug 17, 2020

Conversation

ignacionr
Copy link
Contributor

@ignacionr ignacionr commented Aug 10, 2020

Describe the pull request

  • What does your PR fix?
    Fixes warnings treated as errors on Clang 10.0.0 Linux. Also one unused fn.

  • Which triplets are supported/not supported? Have you updated the CI baseline?
    Does not apply (this is a fix for the tool).

  • Does your PR follow the maintainer guide?
    Yes.

Additional notice (so to understand some of these changes)

  • I like the idea of Span<> being a view into contiguous memory (it basically avoids going through abstracted iterators).

  • When initializing them with vectors, we are making a claim that will not necessarily last: std::vector may need to re-allocate at some point, so it will all move elsewhere. But while within a fn called with a temporary object, it's fairly safe.

  • Clang is wiser than other compilers and won't let us just go ahead and use vectors for that reason. So I changed it to the address of the first element, and the count (totally equivalent, and the potential risks made explicit).

Of course, I may have completely misunderstood something here, so comments and clarifications are very welcome.

Compiler Messages

clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin


/home/ignacio/src/tests/vcpkg/toolsrc/src/vcpkg/base/system.cpp:163:39: error: unused function 'get_xdg_config_home' [-Werror,-Wunused-function]
    static const ExpectedS<fs::path>& get_xdg_config_home() noexcept
                                      ^
1 error generated.
make[2]: *** [CMakeFiles/vcpkglib.dir/build.make:219: CMakeFiles/vcpkglib.dir/src/vcpkg/base/system.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:162: CMakeFiles/vcpkglib.dir/all] Error 2
make: *** [Makefile:95: all] Error 2
/home/ignacio/src/tests/vcpkg/toolsrc/src/vcpkg/build.cpp:303:75: error: unused parameter 'paths' [-Werror,-Wunused-parameter]
    const System::Environment& EnvCache::get_action_env(const VcpkgPaths& paths, const AbiInfo& abi_info)
                                                                          ^
/home/ignacio/src/tests/vcpkg/toolsrc/src/vcpkg/build.cpp:303:97: error: unused parameter 'abi_info' [-Werror,-Wunused-parameter]
    const System::Environment& EnvCache::get_action_env(const VcpkgPaths& paths, const AbiInfo& abi_info)
                                                                                                ^
2 errors generated.
make[2]: *** [CMakeFiles/vcpkglib.dir/build.make:323: CMakeFiles/vcpkglib.dir/src/vcpkg/build.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:162: CMakeFiles/vcpkglib.dir/all] Error 2
make: *** [Makefile:95: all] Error 2

@JackBoosY JackBoosY requested a review from strega-nil August 10, 2020 08:32
@JackBoosY JackBoosY self-assigned this Aug 10, 2020
@strega-nil
Copy link
Contributor

@ignacionr this... seems like an unfortunate change. What warnings does clang throw after passing the vector as a span?

Fwiw, this path has been tread before, by the standards committee, so they agree we're doing the right thing here.

Copy link
Contributor

@ras0219 ras0219 left a comment

Choose a reason for hiding this comment

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

I used docker[1] to get a copy of clang 10 and didn't see a motivation (i.e. compiles without warnings) for two of the changes; otherwise, looks great!

[1] https://solarianprogrammer.com/2017/12/14/clang-in-docker-container-cpp-17-development/

@ignacionr
Copy link
Contributor Author

ignacionr commented Aug 11, 2020

@ignacionr this... seems like an unfortunate change. What warnings does clang throw after passing the vector as a span?

Fwiw, this path has been tread before, by the standards committee, so they agree we're doing the right thing here.

I was able to reproduce this only for a minute on the Visual Studio Code messages. At some point, the messages just disappeared. It may have been related to whatever version of compiler/standard library the IDE was using before re-configuring. I will remove the changes (since they proved unnecessary), as I agree they don't look appealing to read.

They were as follows.

{
	"resource": "/mnt/hdd/src/vcpkg-clean/toolsrc/src/vcpkg/build.cpp",
	"owner": "C/C++",
	"severity": 8,
	"message": "no suitable user-defined conversion from \"const std::vector<std::string, std::allocator<std::string>>\" to \"vcpkg::View<std::string>\" exists",
	"startLineNumber": 170,
	"startColumn": 67,
	"endLineNumber": 170,
	"endColumn": 71
}

{
	"resource": "/mnt/hdd/src/vcpkg-clean/toolsrc/src/vcpkg/build.cpp",
	"owner": "C/C++",
	"severity": 8,
	"message": "no suitable user-defined conversion from \"std::vector<vcpkg::Build::AbiEntry, std::allocator<vcpkg::Build::AbiEntry>>\" to \"vcpkg::Span<const vcpkg::Build::AbiEntry>\" exists",
	"startLineNumber": 962,
	"startColumn": 74,
	"endLineNumber": 962,
	"endColumn": 89
}

But I will keep those that generate warnings (unused fn, unused params).

@ignacionr ignacionr marked this pull request as draft August 11, 2020 01:54
updating use of Span<>

after clang-format

two changes undone
@ignacionr ignacionr marked this pull request as ready for review August 11, 2020 02:24
@ignacionr
Copy link
Contributor Author

@strega-nil @ras0219 this seems ready now. Care to merge?

@strega-nil
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JackBoosY JackBoosY added the category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) label Aug 17, 2020
@strega-nil strega-nil merged commit 5dd2b67 into microsoft:master Aug 17, 2020
@ignacionr ignacionr deleted the fix/clang10-linux branch August 17, 2020 18:24
remz1337 pushed a commit to remz1337/vcpkg that referenced this pull request Aug 23, 2020
updating use of Span<>

after clang-format

two changes undone
strega-nil pushed a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
updating use of Span<>

after clang-format

two changes undone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants