Skip to content

Conversation

@nthirtyone
Copy link
Contributor

Drafted as per discussion in #17096.

I don't have Windows build environment to see how it works there and I'm unsure to what extent this is covered by the tests. Any input is appreciated.

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

lgtm.

I think maybe we should add a test though, there are a few .pc files that get installed in the sysroot by default:

./cache/sysroot/lib/pkgconfig
├── egl.pc
├── glesv2.pc
└── sdl.pc

See tests/cmake for the current cmake tests.. maybe one of these can be modified/updated.

cmake_path(CONVERT "${_em_pkgconfig_libdir}" TO_NATIVE_PATH_LIST _em_pkgconfig_libdir)
endif()
set(ENV{PKG_CONFIG_LIBDIR} "${_em_pkgconfig_libdir}")
set(ENV{PKG_CONFIG_PATH} "$ENV{EM_PKG_CONFIG_PATH}") # Stops caller's PKG_CONFIG_PATH from propagating.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should forget about EM_PKG_CONFIG_PATH. I'm not sure why use it ever had.

If somebody explicitly sets PKG_CONFIG_PATH when building an emscripten project I don't see why should ignore it. That seems like a deliberate act.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This behaviour was based on tools.building.get_building_env().

I agree that it seems a bit out of place, but that would introduce inconsistency in how caller's variables are used across tools. If it's acceptable for you then I'm happy to do it.

Or should I update get_building_env? For example: create a backwards-compatible behaviour that prioritises EM_PKG_CONFIG_PATH but also allows for PKG_CONFIG_PATH, and then implement it consistently inget_building_env and here in toolchain.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should ignore EM_PKG_CONFIG_PATH in this patch and we should try to remove it from get_building_env as separate change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, removed the line in question.

@nthirtyone
Copy link
Contributor Author

nthirtyone commented May 30, 2022

@sbc100, Newly added test seems to work fine after adding pkg-config to Windows and Mac CI environments (as of d439aa8). It checks whether the LIBDIR variable is propagated and set to expected value and if expected packages are visible from CMake's FindPkgConfig (without verifying version to minimise the impact of any upgrades and reduce duplication - I want to add a modversion check for test in #17100).

That being said, I see that test_minimal_runtime_code_size_* are failing because "overall generated code size was improved by 43 bytes." Quick glance at the test made me confused and I cannot reproduce the results locally. Comments there suggest that it might be unrelated, but can't tell just yet.


message(STATUS "PKG_CONFIG_LIBDIR: $ENV{PKG_CONFIG_LIBDIR}")

find_package(PkgConfig REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does this file on machines that don't have pkg-config.

If might be nice to tell the person running the test exactly what is wrong (imagine a windows developer running this test for example).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fails and drops following into stderr:

CMake Error at C:/ProgramData/chocolatey/lib/cmake.portable/tools/cmake-3.23.2-windows-x86_64/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Which could be confusing. Let me add a skip branch that checks whether pkg-config is available in the PATH.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer and explict fail.. so that folks know to install it. Something like if not_in_path: self.fail('pkg-config required to run this test'.

If there are folks who are not able to don't want to install it we can consider adding an EMTEST_SKIP_PKK_CONFIG setting that will allow them to skip over it.. but hopefully it won't be needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

(otherwise the test silently skips on new installations).

Copy link
Contributor Author

@nthirtyone nthirtyone May 31, 2022

Choose a reason for hiding this comment

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

Alright, made it to fail in bfc2f5a. Since I also increased verbosity in the CMake when looking for pkg-config, we could alternatively go with the same approach as test_cmake_with_embind_cpp11_mode has: if WINDOWS and not utils.which('pkg-config'): self.skipTest and on other platforms it would go through this stage and if it wouldn't find pkg-config it would fail due to CMake's non-zero code along with a "Could not find pkg-config executable!" message in stderr.


find_package(PkgConfig REQUIRED)

pkg_check_modules(EGL REQUIRED egl)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a comment here: Emscripten ships .pc files for egl/glesv2/sdl. Check that they can all be located correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a message explaining what the script is trying to do. I reworded it a bit to not contain the list of packages, so that adding a new package won't require modifying the message on top of everything else. I guess we could just go with a full-pledged list and then iterate, create some nice message and so on, but I feel like that'd be an overkill for a test and I'd rather have it dumb simple.

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

lgtm! (with a couple comments). Thanks for working on this.

@sbc100
Copy link
Collaborator

sbc100 commented May 31, 2022

The code size test failures are unrelated.. its something that needs adjusting periodically if there are change to llvm. I'll submit a fix for that and you will need to rebase/merge.

sbc100 added a commit that referenced this pull request May 31, 2022
Also rename the existing `require_node` and `require_v8` decorators.

See #17101
else()
cmake_path(CONVERT "${_em_pkgconfig_libdir}" TO_NATIVE_PATH_LIST _em_pkgconfig_libdir)
endif()
set(ENV{PKG_CONFIG_LIBDIR} "${_em_pkgconfig_libdir}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should also set PKG_CONFIG_SYSROOT_DIR here? (doesn't have to be part of this change).

Copy link
Contributor Author

@nthirtyone nthirtyone May 31, 2022

Choose a reason for hiding this comment

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

I'd suggest to leave it out for now. We'd want to get consistent behaviour for CMake and building.py and PKG_CONFIG_SYSROOT_DIR can easily become a journey on its own (LIBDIR is good enough for most use cases, and SYSROOT affects only the PATH, not LIBDIR).

@sbc100 sbc100 enabled auto-merge (squash) May 31, 2022 20:14
@sbc100 sbc100 merged commit 3b36c26 into emscripten-core:main May 31, 2022
sbc100 added a commit that referenced this pull request Jun 1, 2022
Also rename the existing `require_node` and `require_v8` decorators.

See #17101
sbc100 added a commit that referenced this pull request Jun 1, 2022
Also rename the existing `require_node` and `require_v8` decorators.

See #17101
sbc100 added a commit that referenced this pull request Jun 1, 2022
Also rename the existing `require_node` and `require_v8` decorators.

See #17101
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.

2 participants