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

Worker: Add make update-wrap-file task #938

Merged
merged 4 commits into from Nov 3, 2022
Merged

Conversation

ibc
Copy link
Member

@ibc ibc commented Nov 3, 2022

  • Usage example: make update-wrap-file SUBPROJECT=openssl.

Bonus Tracks

  • Make comments in Makefile respect max length ~80 columns.
  • Order tasks in Makefile.
  • Update libuv by using the new make update-subproject task.

- Usage example: `make update-subproject SUBPROJECT=openssl`.

### Bonus Tracks

- Make comments in `Makefile` respect max length ~80 columns.
- Order tasks in `Makefile`.
- Update `libuv` by using the new `make update-subproject` task.
@ibc ibc requested review from jmillan and nazar-pc November 3, 2022 15:43
@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

Off topic: I did this to update OpenSSL given the recent CVE-2022-3786 and CVE-2022-3602, however last version of OpenSSL in https://mesonbuild.com/Wrapdb-projects.html is still 3.0.2-1, which is really outdated :( How are we supposed to deal with this?

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

Ohhh.... why this? I didn't do anything in this PR that may have caused this...

https://github.com/versatica/mediasoup/actions/runs/3387127006/jobs/5627440846#step:6:124
CleanShot-2022-11-03-at-16 47 10@2x

@jmillan
Copy link
Member

jmillan commented Nov 3, 2022

Ohhh.... why this? I didn't do anything in this PR that may have caused this...

Just do the changes suggested in the error. Can be new version of Meson requires it.

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

Ohhh.... why this? I didn't do anything in this PR that may have caused this...

Just do the changes suggested in the error. Can be new version of Meson requires it.

How can this PR cause that? I didn't change Meson version.

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

How can this PR cause that? I didn't change Meson version.

Change done.

@jmillan
Copy link
Member

jmillan commented Nov 3, 2022

How can this PR cause that? I didn't change Meson version.

I believe is a meson auto update, or a fresh installation in github actions.

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

I'm updating openssl.wrap manually to force version 3.0.7 according to https://www.openssl.org/source/ (SHA256 included):

[wrap-file]
directory = openssl-3.0.7
source_url = https://www.openssl.org/source/openssl-3.0.7.tar.gz
source_filename = openssl-3.0.7.tar.gz
source_hash = 83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e

[provide]
libcrypto = libcrypto_dep
libssl = libssl_dep
openssl = openssl_dep

Then I run make clean-all and make clean-subprojects (just in case) and then make. Unfortunately it fails:

$ make
/Users/ibc/src/v3-mediasoup/worker/out/pip/bin/meson setup \
		--prefix /Users/ibc/src/v3-mediasoup/worker/out/Release \
		--bindir '' \
		--libdir '' \
		--buildtype release \
		-Db_ndebug=true \
		-Db_pie=true \
		-Db_staticpic=true \
		--reconfigure \
		"" \
		/Users/ibc/src/v3-mediasoup/worker/out/Release/build || \
		/Users/ibc/src/v3-mediasoup/worker/out/pip/bin/meson setup \
			--prefix /Users/ibc/src/v3-mediasoup/worker/out/Release \
			--bindir '' \
			--libdir '' \
			--buildtype release \
			-Db_ndebug=true \
			-Db_pie=true \
			-Db_staticpic=true \
			"" \
			/Users/ibc/src/v3-mediasoup/worker/out/Release/build
Directory does not contain a valid build tree:
/Users/ibc/src/v3-mediasoup/worker/out/Release/build
The Meson build system
Version: 0.61.5
Source dir: /Users/ibc/src/v3-mediasoup/worker
Build dir: /Users/ibc/src/v3-mediasoup/worker/out/Release/build
Build type: native build
Project name: mediasoup-worker
Project version: undefined
C compiler for the host machine: cc (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.102)")
C linker for the host machine: cc ld64 819.6
C++ compiler for the host machine: c++ (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.102)")
C++ linker for the host machine: c++ ld64 819.6
Host machine cpu family: x86_64
Host machine cpu: x86_64
Downloading openssl source from https://www.openssl.org/source/openssl-3.0.7.tar.gz
Download size: 15107575
Downloading: ..........

meson.build:163:0: ERROR: Subproject exists but has no meson.build file

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

I'm updating openssl.wrap manually to force version 3.0.7 according to https://www.openssl.org/source/ (SHA256 included):

[wrap-file]
directory = openssl-3.0.7
source_url = https://www.openssl.org/source/openssl-3.0.7.tar.gz
source_filename = openssl-3.0.7.tar.gz
source_hash = 83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e

[provide]
libcrypto = libcrypto_dep
libssl = libssl_dep
openssl = openssl_dep

Then I run make clean-all and make clean-subprojects (just in case) and then make. Unfortunately it fails:

$ make
/Users/ibc/src/v3-mediasoup/worker/out/pip/bin/meson setup \
		--prefix /Users/ibc/src/v3-mediasoup/worker/out/Release \
		--bindir '' \
		--libdir '' \
		--buildtype release \
		-Db_ndebug=true \
		-Db_pie=true \
		-Db_staticpic=true \
		--reconfigure \
		"" \
		/Users/ibc/src/v3-mediasoup/worker/out/Release/build || \
		/Users/ibc/src/v3-mediasoup/worker/out/pip/bin/meson setup \
			--prefix /Users/ibc/src/v3-mediasoup/worker/out/Release \
			--bindir '' \
			--libdir '' \
			--buildtype release \
			-Db_ndebug=true \
			-Db_pie=true \
			-Db_staticpic=true \
			"" \
			/Users/ibc/src/v3-mediasoup/worker/out/Release/build
Directory does not contain a valid build tree:
/Users/ibc/src/v3-mediasoup/worker/out/Release/build
The Meson build system
Version: 0.61.5
Source dir: /Users/ibc/src/v3-mediasoup/worker
Build dir: /Users/ibc/src/v3-mediasoup/worker/out/Release/build
Build type: native build
Project name: mediasoup-worker
Project version: undefined
C compiler for the host machine: cc (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.102)")
C linker for the host machine: cc ld64 819.6
C++ compiler for the host machine: c++ (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.102)")
C++ linker for the host machine: c++ ld64 819.6
Host machine cpu family: x86_64
Host machine cpu: x86_64
Downloading openssl source from https://www.openssl.org/source/openssl-3.0.7.tar.gz
Download size: 15107575
Downloading: ..........

meson.build:163:0: ERROR: Subproject exists but has no meson.build file

which makes sense since, indeed, there is no meson.build file in https://www.openssl.org/source/openssl-3.0.7.tar.gz BUT NEITHER in the previous https://www.openssl.org/source/openssl-3.0.2.tar.gz file!!!

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

So, so the thing is that, in previous openssl.wrap file there were patch fields:

[wrap-file]
directory = openssl-3.0.2
source_url = https://www.openssl.org/source/openssl-3.0.2.tar.gz
source_filename = openssl-3.0.2.tar.gz
source_hash = 98e91ccead4d4756ae3c9cde5e09191a8e586d9f4d50838e7ec09d6411dfdb63
patch_filename = openssl_3.0.2-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/openssl_3.0.2-1/get_patch
patch_hash = 762ab4ea94d02178d6a1d3eb63409c2c4d61315d358391cdac62df15211174d4

[provide]
libcrypto = libcrypto_dep
libssl = libssl_dep
openssl = openssl_dep

This makes Meson fetch a special patch file from https://wrapdb.mesonbuild.com/v2/openssl_3.0.2-1/get_patch which is a zip file that contains meson.build and many other Meson related stuff :(

CleanShot-2022-11-03-at-17 21 26@2x

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

ok, this is too much for me...
CleanShot-2022-11-03-at-17 23 03@2x

Maybe caused by issue rust-lang/rust-clippy#9538 which may be fixed by PR rust-lang/rust-clippy#9662.

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

Ok, I've compared openssl-3.0.2 and openssl-3.0.7 taking into account the patched file of Meson for openssl-3.0.2. AFAIS nothing prevents us from using the same openssl_3.0.2-1_patch.zip from wrapdb.mesonbuild.com in openssl-3.0.7.

However it's not gonna work since the path zip must contain a folder with same name as the desired subproject to patch, which in our case is openssl-3.0.7, however openssl_3.0.2-1_patch.zip from wrapdb.mesonbuild.com contains a openssl-3.0.2 folder as content (as expected). So same meson.build not found error...

@jmillan
Copy link
Member

jmillan commented Nov 3, 2022

However it's not gonna work since the path zip must contain a folder with same name as the desired subproject to patch,...

It's not that straightforward,

There are specific instructions to create/update meson wrap subprojects here https://mesonbuild.com/Adding-new-projects-to-wrapdb.html

@ibc ibc changed the title Worker: Add make update-subproject task Worker: Add make update-wrap-file task Nov 3, 2022
@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

There are specific instructions to create/update meson wrap subprojects here https://mesonbuild.com/Adding-new-projects-to-wrapdb.html

I see. However take a look to how complex making this for a new openss version is. This is the README in the patch file in mesonbuild for openssl-3.0.2:

OpenSSL for Meson

How this works?

TL;DR: this wrap abuses OpenSSL build system within Node.js.

Node.js has OpenSSL built-in with additional scripting around it to generate configs for GYP build system and thus bypass OpenSSL's native build system.

This wrap abuses that feature by replacing bundled OpenSSL with upstream version, patching mentioned mechanism to also generate a bunch of meson.build files for different platforms and uses top-level meson.build to wire everything together.

During installation unmodified Node.js tarball will be downloaded, its bundled OpenSSL will be replaced with upstream version and patched with meson.build files, enabling ability to build OpenSSL with Meson 🎉.

How to update to newer release

Unless Node.js changes the mechanism we abuse above (unlikely, but possible, please check the diff between corresponding versions), generator.sh file can be used.

Just update OpenSSL version in wrap file, update Node.js version in generator.sh file to such that contains matching OpenSSL version bundled with it and run generator.sh from the root of the repository:

subprojects/packagefiles/openssl/generator.sh

Generated files in generated-config directory, after which you can try to build it. create_release.py will run it as part of the release process, so it doesn't need to be included in Git.

Acknowledgement

This OpenSSL port wouldn't be possible without Node.js project under MIT license, whose OpenSSL build system was decomposed and heavily refactored.

@jmillan
Copy link
Member

jmillan commented Nov 3, 2022

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

I'll create a new ticket for the openssl update stuff and leave this PR just for what it was intended: add a new make task update-wrap-file.

@nazar-pc
Copy link
Collaborator

nazar-pc commented Nov 3, 2022

How can this PR cause that? I didn't change Meson version.

This and other might be related to Rust version upgrade. Run rustup update and it may fix those if you were running an older version. If you're running a newer instead you (or I) will need to fix those, clippy improves suggestions over time, adds new lints and improves existing ones. We have CI configured to not allow any warnings whatsoever.

As to OpenSSL update you'll need to update it in Meson wraps first unless someone else did it. According to https://mesonbuild.com/Wrapdb-projects.html version there is quite old and needs to be updated, you can see one of the PRs I did and follow readme as you already noticed. For instance here: mesonbuild/wrapdb#281

Same about libuv, here is an example of upgrade (basically read upstream CMakeLists changes and tweak meson.build): mesonbuild/wrapdb#367

@nazar-pc
Copy link
Collaborator

nazar-pc commented Nov 3, 2022

New Rust version was just released earlier today, so this is probably why you hit those warnings, I'll send a PR fixing them.

@ibc
Copy link
Member Author

ibc commented Nov 3, 2022

Guys, let's please manage the OpenSSL version issue in here: #939

@nazar-pc assuming that you are gonna fix the Rust "clippy" related issues in a separate PR, are we good with this PR?

Copy link
Collaborator

@nazar-pc nazar-pc left a comment

Choose a reason for hiding this comment

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

@nazar-pc assuming that you are gonna fix the Rust "clippy" related issues in a separate PR, are we good with this PR?

Yes, looks fine to me

@ibc ibc merged commit e3cf83d into v3 Nov 3, 2022
@ibc ibc deleted the add-make-update-subproject branch November 3, 2022 18:43
piranna pushed a commit to dyte-in/mediasoup that referenced this pull request Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants