* Successfully replaced pushd/popd with CMake's -S/-B in gen-buildsys.sh
for native and clr. Now, looking into removing other instances if
possible.
* Removed redundant pushd/popd in src/native/libs/build-native.cmd
* Experimenting with removing 'pushd/popd' for Wasm/Wasi.
* Restored pushd/popd to eng/native/build-commons.sh because it is
actually not directly related to CMake.
* Add explicit exit code to gen-buildsys.sh
Make sure we don't forget to return the cmake exist code, see https://github.com/dotnet/runtime/pull/95408.
* Replace with comment instead
---------
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Follow-up on #32451
Follow-up on #80074
In #43651, the "Windows" OS name was lowercased to achieve target frameworks with RIDs in them. At that time, the original plan was to lowercase all TargetOS values but that had to be cut because of resources. This PR finishes that and updates build systems, YML, markdowns and managed components.
To not break existing developer workflows, the passed-in -os value is automatically lower-cased in the script entry points and validated in the msbuild entry point.
When cmake configuration fails due to missing dependency or manually terminated in the middle (Ctrl+C) for some reason, re-running the build command fails with these messages:
```
CMake command line is unchanged. Reusing previous cache instead of regenerating.
Unable to find generated build files for "native libraries component" project!
```
The workaround is to delete artifacts directory and rerun the build command, which is wasteful (as it repreforms all the previous steps including rebuilding the previous subsets). cmake has its own up-to-date caching mechanism which works well on Unix (it has some issues on Windows/MSBuild), so deleting the custom sentinel-based cache on Unix makes it more robust and saves some time. The one in `gen-buildsys.cmd` for Windows is kept intact.
When user passes versioned native compiler argument such as
`-clang10.1` or `-gcc9.2` to the top-level `:/build.sh`,
`:/eng/build.sh` transforms that to msbuild property called
`<Compiler>` with raw/unprocessed value.
In coreclr, libs, corehost and tests partitions, we end up calling
`:/eng/native/build-commons.sh`, which slices the compiler name, major
and minor versions, then calls `:/eng/native/gen-buildsys.sh` with
individual components. That is just a pass-thru script for the final
`:/eng/common/native/init-compiler.sh`, where those arguments are
actually used.
In `mono.proj` and `NativeExports.csproj`, we do not use
`build-commons` script, but instead, invoke `init-compiler.sh` directly
with the raw `<Compiler>` property. That causes an error when versioned
native compiler is specified on the command line.
This PR fixes this issue by pushing version parsing code into
`init-compiler.sh` so all its consumers get the same behavior.
Fixes an issue where deleting the intermediates folder locally would get the build in a bad state where the command-line check would be up to date but the CMake files would not be generated.
* from prototype
* fix OSX
* fix for Android
* treat "libSystem.Globalization.Native" as QCall in mono too (for now).
* fix for wasm
* fix pedantic errors on GCC
* delete gPalGlobalizationNative
* pass overrider from the host
* default override
* default PInvoke override runs after optional host-provided overrider.
* Some PR feedback (mostly related to code, not the CMake stuff).
* more coding PR feedback
* Deleted "libraries-native" folder.
* unifying tryrun.cmake into 1 common file
* factor out adding lib-specific dependencies into one place (per native library)
* cleanup: entirely remove tryrun.cmake propagation in eng, gen-buildsys, build-commons, and build scripts
* remove "clrcompression.dll" and "libSystem.IO.Compression.Native.dylib" from single-file host packaging
* mono: refactor Globalization lookup into `default_resolve_dllimport`.
* set FEATURE_DISTRO_AGNOSTIC_SSL according to __PortableBuild
* CORECLR_CALLING_CONVENTION for the host callback types
* refactor common parts of entrypoints.c into entrypoints.h
* rename OverrideEntry --> DllImportEntry
* extra libs as CMake functions
* use macros instead of functions in extra_libs.cmake
* mono formatting style in src/mono/mono/metadata/native-library.c
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
* mono: Remaining stylistic nits.
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
* do not set DFEATURE_DISTRO_AGNOSTIC_SSL on iOS, Android, tvOS
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
* Move DacTableGen out of the CMake build and into tools-local.
* Attempt: usenmakefiles means ninja.
* Make changes to Windows build to support non-VS generators like ninja.
* Use CMake 3.16 PCHs.
* Remove explicit process count.
* Build and run DacTableGen via the .NET CLI we pull down for the build instead of via CMake.
* Update configurecompiler.cmake to specify language (needed for Ninja).
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Get Ninja build working again.
* Pass configuration to cmake configure step for Ninja build.
* Rename flag
* Fix configure step for cross-arch native build
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Support building via Ninja for coreclr via an MSBuild property
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Implement support for opening the CoreCLR solution in VS via the -vs flag.
* Fix setting generator to Ninja.
* Merge libraries gen-buildsys-win.bat with runtime gen-buildsys.cmd to share windows cmake configure infra.
* Enable building libraries native build with ninja.
* Centralize setting CMAKE_SYSTEM_VERSION for windows builds.
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Update host build to use shared gen-buildsys.cmd
* Fix multi-config generator detection.
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Exit with success when we build successfully.
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Enable and fix up Ninja build for hosts.
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Only link delayimp.lib on Windows
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Remove "overriding /W3 with /W1" warning in Ninja build of hosts by turning on /W3 and disabling any new warnings we hit.
* Reduce command line override warnings by adopting the MSVC_RUNTIME_LIBRARY abstraction feature in CMake 3.14+ (below the minimum requirement on Windows).
* Use the delayed expansion syntax to correctly pass in the config to cmake.
* Move all usages of MSVC runtime library selection to the CMake abstraction to reduce console spew about overridden flags.
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Condition the rest of the compiler options correctly so they don't show up as invalid parameter warnings for assembly builds.
* Correctly build DIALib and DacTableGen as AnyCPU
* Fix WRITE_BARRIER_CHECK define
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Fix passing arch for MSBuild build.
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Configure ASM compiler command line format in configurecompiler.cmake and use CMake's assembly compilation step to build ASM files for ARM/ARM64 instead of manually building them and adding the generated files as additional sources.
* Cleanup after fixing ARM/ARM64 support.
* Rename variable
* Condition PCH's for C++-only as needed to fix using them on non-Windows (where we compile C as C instead of as C++).
* Fix CoreCLR native test build on windows to point to new gen-buildsys location.
* Add missing compilation options in Ninja build that are implicitly defined in the MSBuild build.
* Disable analyzers for DacTableGen. Remove /MAP linker flag (that's for local testing).
* Upgrade to CMake 3.16.4
* Don't warn on unused variables in CMake (these usually vary on platform/config)
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Manually compile ARM and ARM64 asm files when using the VS generator since it doesn't support emitting MARMASM item types in projects (and as a result cannot compile ARM or ARM64 asm without assistance).
* Enable CMake policy in test build to use CMAKE_MSVC_RUNTIME_LIBRARY variable.
* Update initially disabled warnings in host.
* Add -ninja arg to root scripts to enable using Ninja.
* Enable using Ninja in CoreCLR CI.
* Try to fix passing the -ninja arg in yaml.
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Add ninja to the Windows invocation
* Fix 2-phase cross targeting to do one phase at a time and initialize the VC++ environment for the correct build tools each time instead of interleaving them and relying on Visual Studio to handle the differing targets.
* Restore old /Ox optimization setting for Release.
* Fix typos, don't pass exception flags to C files.
* Remove unneeded pragma.
* Fix .pgd file installation.
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Add mention of the `-ninja` flag in the Building CoreCLR documentation.
Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
* Mention installation locations for Ninja and warn while building if CMake is older than 3.16.0.
* Update docs/workflow/requirements/windows-requirements.md
* Set emcc as the compiler for libraries build
* Add default subsets for webassembly build
* Fix various problems in the build
* Use WebAssembly Docker image
* Use Mono runtime for webassembly builds
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
`desired_version` lives in `init-compiler.sh`.
Also clear the existing CC and CXX preset by environment to avoid unexpected overriding. (the only way to override compiler tools is using CLR_* vars: CLR_CC, CLR_CXX, CLR_AR and so on)
* Fix typo in gen-buildsys.sh
compier -> compiler
* Extract detecting CC/CXX into helper script so we can use it from mono.proj
* Rename detect-compiler.sh to init-compiler.sh
* Unify build_native via eng/native/build-commons
In order to add new platform, architecture, compiler or its newer
version, there are currently multiple places to update, which can be
deduplicated.
This patch unifies:
* directories creation
* prerequisites checking
* `version.c` generation
* native build invocation
* common argument parsing
* building help menu
for various build scripts under coreclr, installer and libraries.
The common entry-point script is now `eng/native/build-commons.sh` and
rest of the scripts under `eng/native` are implementation detail.
Also extracted CMake platform detection in
`eng/native/configureplatform.cmake`, to share with coreclr and
`installer/corehost`.
* Use if [[ cond ]] in all places