microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22k stars 6.12k forks source link

[nss] Add new ports nspr and nss #21281

Closed plq closed 2 years ago

plq commented 2 years ago

Describe the pull request

ghost commented 2 years ago

CLA assistant check
All CLA requirements met.

dg0yt commented 2 years ago

Better don't touch vcpkg_build_make unless needed, or in a separate PR: Each push will trigger a CI rebuild of all ports that depend on this function, taking many hours.

JackBoosY commented 2 years ago

Please get failure logs here. If you need some help, please ping me.

plq commented 2 years ago

Better don't touch vcpkg_build_make unless needed, or in a separate PR: Each push will trigger a CI rebuild of all ports that depend on this function, taking many hours.

done: #21296

plq commented 2 years ago

Hey @JackBoosY, thanks for your close interest.

Please get failure logs here. If you need some help, please ping me.

I don't have the resources to deal with all these platforms. The x64-windows dlls seem to work fine so far. I made sure the 32bit target builds but haven't tested the binaries. They should work, though. I can't comment about the others.

As for the logs, except for the spurious 502 from V8 source repo, the only issue I see is vcpkg_find_acquire forgetting about NSINSTALL. I don't see why it wouldn't work, perhaps you are hiding some of the untrusted changes from your CI?

plq commented 2 years ago

For completeness' sake, here's the stdout from x64-windows

-- Downloading https://releases.mozilla.org/pub/nspr/releases/v4.32/src/nspr-4.32.tar.gz -> nspr-4.32.tar.gz...
FATALunknown tool NSINSTALL -- unable to acquire.
CMake Error at scripts/cmake/vcpkg_find_acquire_program.cmake:493 (find_program):
  find_program called with incorrect number of arguments
Call Stack (most recent call first):
  scripts/cmake/vcpkg_find_acquire_program.cmake:534 (do_find)
  ports/nspr/portfile.cmake:14 (vcpkg_find_acquire_program)
  scripts/ports.cmake:142 (include)
plq commented 2 years ago

I'll try to make your job easier by providing some questions to discuss:

  1. I removed mozbuild from vcpkg_find_acquire_program (vfap)

    If you don't want mozbuild in vcpkg_find_acquire_program (vfap), I can move it inside the ebuild. NSS needs GYP to build as well but I didn't put it inside vfap as it's a dead project and don't think it'll be useful elsewhere. mozbuild on the other hand is like chromium's depot_tools and could come in handy.

    your choice, though.

  2. I do weird things with headers: NSS has two sets of headers: public and private. public headers are put in include/nss/nss and private ones are put in include/nss/private/nss. Users wouldn't notice anything with an accompanying FindNSS.cmake that deals with these quirks but I can't say I'm entirely happy with the current state of things.

    so with all this said, what's vcpkg's policy regarding private headers?

    1. ignore them
    2. put them together with public headers
    3. put them in a subfolder inside public headers
    4. keep the status quo and offer them as a separate component along with a custom FindNSS.cmake

    thoughts?

  3. The build also produces some .exe files. I put them inside bin but the QA bits complained so I removed them. Currently they are being ignored. What do you want me to do with them?

  4. It seems that the NSS build system also signs the produced binaries. It didn't work and I disabled it. I'm not sure it's supposed to work on random people's computers. I don't really care as we sign our installers anyway.

That's all I can think of. This one is may be second only to openssl in terms of weirdness of its build system :) Why do crypto libs are like this? They are the flakiest pieces of software we need to deal with, so need to be as easy to build as possible.

:man_shrugging:

plq commented 2 years ago

the ebuilds were rebased on latest master, with mozbuild removed from vfap

JackBoosY commented 2 years ago

Sorry for late, I will handle this tomorrow.

plq commented 2 years ago

Here it says the latest stable release is 3.66: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Releases

There seem to be newer releases (newest is currently 3.72) and actually seems legitimate but couldn't be sure.

JackBoosY commented 2 years ago

I removed mozbuild from vcpkg_find_acquire_program (vfap)

Agreed, if the build system is too complex, we should add a new port instead of that.

I do weird things with headers: NSS has two sets of headers: public and private. public headers are put in include/nss/nss and private ones are put in include/nss/private/nss. Users wouldn't notice anything with an accompanying FindNSS.cmake that deals with these quirks but I can't say I'm entirely happy with the current state of things. \ so with all this said, what's vcpkg's policy regarding private headers?

If there is a call relationship between public header files and private header files, we still need to install them in the subfolders of include, because users actually need to use them. If not, we should follow the upstream rules to choose whether to install them.

The build also produces some .exe files. I put them inside bin but the QA bits complained so I removed them. Currently they are being ignored. What do you want me to do with them?

For those executables, they serve two purposes:

  1. Generate to execute test cases, for them we should not install/generate or delete directly after installation
  2. To generate tools, we should record their names and install them in tools/${PORT} using vcpkg_copy_tools. See documentation.

It seems that the NSS build system also signs the produced binaries. It didn't work and I disabled it. I'm not sure it's supposed to work on random people's computers. I don't really care as we sign our installers anyway.

Yeah, some binaries, such as boost's build tool b2, also have this problem: the official binary is signed, but the code generated locally is not signed, which may cause the anti-virus report to be abnormal. The signature requires an official certificate, and there is nothing we can do about it. But users can trust the generated binaries: because we use official codes to generate them, they are safe from the perspective of sources.

JackBoosY commented 2 years ago

For new ports:

  1. If some architectures are not officially supported, we should add the supports field in vcpkg.json to filter these architectures. Please use a blacklist instead of a whitelist to avoid unofficial triplets unable to build. See documentation.
  2. If support cannot be added in some official triplets for the time being, we should set these triplets to fail in scripts/ci.baseline.txt. You can check this file to get some examples.
plq commented 2 years ago
JackBoosY commented 2 years ago

Please get failure logs here.

plq commented 2 years ago

CI fails because ninja can't be found. I have it installed here: https://github.com/microsoft/vcpkg/pull/21281/commits/56c7a885df938606ea5caf08028dbf3c0f855e06#diff-960b668db44aad86a4013785856a99f980c4ee1337669d221b12aa17ca7cc130R23

I don't understand the problem here. Any input @JackBoosY ?

Thanks!

plq commented 2 years ago

Please get failure logs here.

Yes, I looked at them. The error is very simple:

Building NSS requires an installation of ninja: https://ninja-build.org/

How do I make sure ninja is found? This builds without any problems on my system.

I'm using https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/ I'm using cmake and ninja that are installed by visual studio installer

plq commented 2 years ago

https://groups.google.com/a/mozilla.org/g/dev-tech-crypto/c/aV_2AJaPimI

JackBoosY commented 2 years ago

I can't repro this on my local machine which using Visual Studio 2017.

plq commented 2 years ago

I can't repro this on my local machine which using Visual Studio 2017.

Can you be a bit more specific? Is it working or is it not working?

JackBoosY commented 2 years ago

@plq It built fine on my local machine. I will try to improve the code.

JackBoosY commented 2 years ago

We can convert mozbuild part to vcpkg_*_mozbuild, but only these two ports are using them, which is not worth it.

plq commented 2 years ago

Vanilla GYP doesn't work with MSVC 17 aka Visual Studio 2022. You need to use my fork (https://github.com/plq/gyp/) for it to work.

JackBoosY commented 2 years ago

@plq We can only accept the official tools/sources, maybe we should wait for upstream approve your changes and update it in the official master branch.

plq commented 2 years ago

GYP is abandoned, there is no upstream to approve my (or anybody else's) changes.

JackBoosY commented 2 years ago

I checked the source, and I found configure/make in it. Maybe we can swith to vcpkg_*_make.

plq commented 2 years ago

Readme says the make-based build system is legacy and can be removed in future, that's why I went with GYP-based one.

I don't think GYP belongs in vcpkg_fetch_acquire because:

  1. It's abandoned, nobody is using it
  2. Vanilla version doesn't work with nss/windows/msvc17 combination

Frankly, I don't see the difference between

https://github.com/plq/gyp/archive/b3177c3f6c2c45a8ca098ae0f0ebb4536c624762.zip

and

https://github.com/chromium/gyp/archive/d6c5dd51dc3a60bf4ff32a5256713690a1a10376.zip

So you need to either bend your official tools policy for this one or drop this pull request.

JackBoosY commented 2 years ago

@plq If the upstream approve your changes, I think we can use your repo 😃

plq commented 2 years ago

image

plq commented 2 years ago

hahaha seriously though, GYP is abandoned and there is no upstream. Chrome switched to GN, NodeJS forked it as gyp-next and maybe I should name this as gyp-nss and be done with it?

JackBoosY commented 2 years ago

@plq Also you should use the same license with gyp.

plq commented 2 years ago

@plq Also you should use the same license with gyp.

No problem. https://github.com/plq/gyp-nss

plq commented 2 years ago

So, are we done? Should I flag this as "ready for review"?

plq commented 2 years ago

This is a new experimental fast check for PR issues. Please let us know if this bot is helpful! PRs must add only one version and must not modify any published versions

for the record, this is very annoying

JackBoosY commented 2 years ago

This is a new experimental fast check for PR issues. Please let us know if this bot is helpful! PRs must add only one version and must not modify any published versions

for the record, this is very annoying

That's for the version control.

JackBoosY commented 2 years ago

When building nss:

[749/842] ninja -t msvc -e environment.x64 -- "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe" /nologo /showIncludes /FC @obj\nss-tool\hw-support.hw-support.obj.rsp /c ..\..\nss-tool\hw-support.c /Foobj\nss-tool\hw-support.hw-support.obj /Fdobj\nss-tool\hw-support.c.pdb 
FAILED: obj/nss-tool/hw-support.hw-support.obj 
ninja -t msvc -e environment.x64 -- "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe" /nologo /showIncludes /FC @obj\nss-tool\hw-support.hw-support.obj.rsp /c ..\..\nss-tool\hw-support.c /Foobj\nss-tool\hw-support.hw-support.obj /Fdobj\nss-tool\hw-support.c.pdb 
d:\buildtrees\nss\x64-windows-dbg\nss\lib\freebl\blapii.h(83): error C2143: syntax error: missing ')' before '*'
d:\buildtrees\nss\x64-windows-dbg\nss\lib\freebl\blapii.h(83): error C2143: syntax error: missing '{' before '*'
d:\buildtrees\nss\x64-windows-dbg\nss\lib\freebl\blapii.h(83): error C2059: syntax error: 'type'
d:\buildtrees\nss\x64-windows-dbg\nss\lib\freebl\blapii.h(83): error C2059: syntax error: ')'

And please apply this patch.

plq commented 2 years ago

When building nss:


FAILED: obj/nss-tool/hw-support.hw-support.obj 

Interesting, builds fine here

And please apply this patch.

{"$id":"1","innerException":null,"message":"TF400813: The user 'Windows Live ID\\<redacted>' is not authorized to access this resource.","typeName":"Microsoft.TeamFoundation.Framework.Server.UnauthorizedRequestException, Microsoft.TeamFoundation.Framework.Server","typeKey":"UnauthorizedRequestException","errorCode":0,"eventId":3000}
JackBoosY commented 2 years ago

unzip this file to get patch.

plq commented 2 years ago

unzip this file to get patch.

done

plq commented 2 years ago

When building nss:

[749/842] ninja -t msvc -e environment.x64 -- "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe" /nologo /showIncludes /FC @obj\nss-tool\hw-support.hw-support.obj.rsp /c ..\..\nss-tool\hw-support.c /Foobj\nss-tool\hw-support.hw-support.obj /Fdobj\nss-tool\hw-support.c.pdb 
FAILED: obj/nss-tool/hw-support.hw-support.obj 
ninja -t msvc -e environment.x64 -- "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe" /nologo /showIncludes /FC @obj\nss-tool\hw-support.hw-support.obj.rsp /c ..\..\nss-tool\hw-support.c /Foobj\nss-tool\hw-support.hw-support.obj /Fdobj\nss-tool\hw-support.c.pdb 
d:\buildtrees\nss\x64-windows-dbg\nss\lib\freebl\blapii.h(83): error C2143: syntax error: missing ')' before '*'
d:\buildtrees\nss\x64-windows-dbg\nss\lib\freebl\blapii.h(83): error C2143: syntax error: missing '{' before '*'
d:\buildtrees\nss\x64-windows-dbg\nss\lib\freebl\blapii.h(83): error C2059: syntax error: 'type'
d:\buildtrees\nss\x64-windows-dbg\nss\lib\freebl\blapii.h(83): error C2059: syntax error: ')'

I dug this a bit. Here's my theory:

JackBoosY commented 2 years ago

Sorry for late, I will handle this tomorrow. I'm really busy.

JackBoosY commented 2 years ago

Will handle this tomorrow.

JackBoosY commented 2 years ago

Reproducing now.

JackBoosY commented 2 years ago

Can't reproduce it locally, curious why it happened.

JackBoosY commented 2 years ago
[730/826] ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x86\cl.exe" /nologo /showIncludes /FC @obj\nss-tool\hw-support.hw-support.obj.rsp /c ..\..\nss-tool\hw-support.c /Foobj\nss-tool\hw-support.hw-support.obj /Fdobj\nss-tool\hw-support.c.pdb 
FAILED: obj/nss-tool/hw-support.hw-support.obj 
ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x86\cl.exe" /nologo /showIncludes /FC @obj\nss-tool\hw-support.hw-support.obj.rsp /c ..\..\nss-tool\hw-support.c /Foobj\nss-tool\hw-support.hw-support.obj /Fdobj\nss-tool\hw-support.c.pdb 
d:\buildtrees\nss\x86-windows-dbg\nss\lib\freebl\blapii.h(83): error C2143: syntax error: missing ')' before '*'
d:\buildtrees\nss\x86-windows-dbg\nss\lib\freebl\blapii.h(83): error C2143: syntax error: missing '{' before '*'
d:\buildtrees\nss\x86-windows-dbg\nss\lib\freebl\blapii.h(83): error C2059: syntax error: 'type'
d:\buildtrees\nss\x86-windows-dbg\nss\lib\freebl\blapii.h(83): error C2059: syntax error: ')'

line 83 is:

SECStatus generate_prime(mp_int *prime, int primeLen);

mp_int was not recognized by the compiler.

Maybe need to repro it with Visual Studio 2019, will retry now.

plq commented 2 years ago

to confirm (or deny) my theory, try to compile that unit with /showIncludes to see whether the correct mpi.h gets included

JackBoosY commented 2 years ago

to confirm (or deny) my theory, try to compile that unit with /showIncludes to see whether the correct mpi.h gets included

I don't think so, if the header mpi.h was not included, it will report a different compiler error.

plq commented 2 years ago

to confirm (or deny) my theory, try to compile that unit with /showIncludes to see whether the correct mpi.h gets included

I don't think so, if the header mpi.h was not included, it will report a different compiler error.

I'm not saying that mpi.h is not being found, I'm saying that maybe the wrong mpi.h is being found

JackBoosY commented 2 years ago

All the mpi.h:

Which header should we use?

plq commented 2 years ago

None, nss comes with its own mpi.h. see my comment above: https://github.com/microsoft/vcpkg/pull/21281#issuecomment-1007448956

plq commented 2 years ago

msmpi:x86-windows:mpi.h

This can be the only culprit as it installs itself in the include dir root.