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

Add warning message for change in default triplet to host triplet #881

Merged
merged 15 commits into from
Feb 14, 2023

Conversation

dan-shaw
Copy link
Contributor

@dan-shaw dan-shaw commented Feb 1, 2023

No description provided.

@autoantwort
Copy link
Contributor

So it will always change to x64-windows even on arm64 windows systems? Or will it change to what the system is like on every other os?

@dan-shaw
Copy link
Contributor Author

dan-shaw commented Feb 3, 2023

What is the current default triplet for arm64 windows systems? I'm guessing it is x86-windows and it should be arm64-windows.

@dg0yt
Copy link
Contributor

dg0yt commented Feb 3, 2023

I think the user expects a native build. So the default triplet should generally become what is the auto-detected host triplet. Even x86-windows for those machines.

@Neumann-A
Copy link
Contributor

i thinkl the default triplet should be the detected host triplet. I mean vcpkg already as a default for that right?

@BillyONeal
Copy link
Member

I think the user expects a native build. So the default triplet should generally become what is the auto-detected host triplet. Even x86-windows for those machines.

I'm pretty sure that already doesn't work because we try to fetch amd64 dependencies.

}
else
{
for (auto&& arg : args.command_arguments)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this trigger on vcpkg search or vcpkg create or vcpkg find?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought those commands do not use the default triplet?

Copy link
Contributor

Choose a reason for hiding this comment

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

Then that's good -- the answer's no. I just wanted to confirm that you've checked them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh -- does this trigger on an invalid command? vcpkg asdf zlib?

Copy link
Member

Choose a reason for hiding this comment

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

Yes it will trigger for that.

@dan-shaw dan-shaw changed the title Add warning message for change in default triplet to x64-windows Add warning message for change in default triplet to host triplet Feb 8, 2023
Comment on lines 1046 to 1050
DECLARE_MESSAGE(DefaultTriplet,
(msg::triplet),
"",
"Starting with the September 2023 release, the default triplet for builds will change from "
"x86-windows to the detected host triplet ({triplet}).");
Copy link
Member

@BillyONeal BillyONeal Feb 8, 2023

Choose a reason for hiding this comment

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

We need to tell the user what to do about the message if they want it to go away:

Starting with the September 2023 release, the default triplet for builds will change from x86-windows to the detected host triplet ({triplet}). To resolve this message, add --triplet {triplet} for the new value, or --triplet {value} to keep the same behavior after the change.

}
else
{
for (auto&& arg : args.command_arguments)
Copy link
Member

Choose a reason for hiding this comment

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

I'm really not a fan of assuming that the command arguments are ports regardless of the executed command like this. For instance, I believe this will do the wrong thing for things like add artifact. (That is vcpkg add artifact gcc should not emit a warning but I believe this will make it do so)

I think commands that are calling check_and_get_full_package_spec need different handling here than commands that do not.

@BillyONeal
Copy link
Member

You might want to consider something like:

struct DefaultTripletProvider {
    DefaultTripletProvider(Triplet current_default_triplet, Triplet new_default_triplet)
        : current_default_triplet(current_default_triplet)
        , new_default_triplet(new_default_triplet)
        , provided(current_default_triplet == new_default_triplet) // don't print if there is no change
    {
    }

    Triplet get() {
        if (!std::exchange(provided, true)) {
            // print the message
        }

        return new_default_triplet;
    }

private:
    Triplet current_default_triplet;
    Triplet new_default_triplet;
    bool provided;
};

then pass this around instead of the naked triplet through all the bits that are processing user input. Then, so long as they never call get(), they emit no warning.

In particular,

    // in commands.interface.h
    struct TripletCommand
    {
        virtual void perform_and_exit(const VcpkgCmdArguments& args,
                                      const VcpkgPaths& paths,
                                      Triplet default_triplet,
                                      Triplet host_triplet) const = 0;
        virtual ~TripletCommand() = default;
    };

    // in input.h
    FullPackageSpec check_and_get_full_package_spec(std::string&& spec_string,
                                                    Triplet default_triplet,
                                                    ZStringView example_text,
                                                    const VcpkgPaths& paths);

would become:

    struct TripletCommand
    {
        virtual void perform_and_exit(const VcpkgCmdArguments& args,
                                      const VcpkgPaths& paths,
                                      DefaultTripletProvider& default_triplet,
                                      Triplet host_triplet) const = 0;
        virtual ~TripletCommand() = default;
    };

    FullPackageSpec check_and_get_full_package_spec(std::string&& spec_string,
                                                    DefaultTripletProvider& default_triplet,
                                                    ZStringView example_text,
                                                    const VcpkgPaths& paths);

@@ -96,6 +96,7 @@ namespace vcpkg::Commands::Upgrade
const std::vector<PackageSpec> specs = Util::fmap(args.command_arguments, [&](auto&& arg) {
return check_and_get_package_spec(std::string(arg), default_triplet, COMMAND_STRUCTURE.example_text, paths);
});
print_default_triplet_warning(args, args.command_arguments);
Copy link
Contributor

Choose a reason for hiding this comment

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

vcpkg upgrade shouldn't emit a warning -- it doesn't use the target triplet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, while I was making this comment before I made a mistake; vcpkg upgrade alone shouldn't emit a warning. However, vcpkg upgrade zlib does use the target triplet.

So, specifically, when args.command_arguments is empty, we should not emit a warning.

Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -305,6 +305,7 @@ namespace vcpkg::Commands::DependInfo
return check_and_get_full_package_spec(
std::string{arg}, default_triplet, COMMAND_STRUCTURE.example_text, paths);
});
print_default_triplet_warning(args, args.command_arguments);
Copy link
Member

Choose a reason for hiding this comment

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

I still think it would be better to do this as part of check_and_get_full_package_spec but that's nitpick territory.

@ras0219-msft
Copy link
Contributor

I made a mistake in my previous comment on commands.upgrade.cpp -- please take a look again.

dan-shaw and others added 2 commits February 13, 2023 15:15
# Conflicts:
#	include/vcpkg/base/messages.h
#	locales/messages.json
#	src/vcpkg/base/messages.cpp
@BillyONeal BillyONeal merged commit 3e20dcc into microsoft:main Feb 14, 2023
@BillyONeal
Copy link
Member

Thanks a bunch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants