Skip to content

Conversation

vmoroz
Copy link
Member

@vmoroz vmoroz commented Jul 13, 2025

Overview

This PR centralizes Windows build configuration, improves build script maintainability, and resolves several security and build issues.

🔧 Build System Improvements

Centralized Windows Configuration

  • Created HermesWindows.cmake to consolidate Windows-specific build logic
  • Moved compiler flags, linker options, and platform detection from scattered locations
  • Unified ARM64/ARM64EC handling and cross-compilation logic
  • Simplified CMakePresets.json by removing embedded flags

Enhanced Build Script (build.js)

  • Added --targets parameter for selective builds (e.g., --targets hermesc,libshared)
  • Improved argument parsing with better validation
  • Enhanced error handling and logging
  • Fixed ARM64EC compiler selection logic

🛡️ Security & Compliance Fixes

BinSkim Security Issues

  • Added proper security flags (/guard:cf, /GS, /DYNAMICBASE, /ZH:SHA_256)
  • Configured deterministic builds with /BREPRO
  • Added CET compatibility for supported platforms
  • Implemented conditional flag application based on target architecture

MSVC Warning/Error Resolution

  • Fixed C4703 "potentially uninitialized variable" errors in external dtoa library
  • Resolved conflicts between /sdl security flags and external code
  • Improved warning suppression for third-party dependencies

🧹 Code Quality Improvements

JavaScript Build Scripts

  • Added ESLint and Prettier configuration for consistent code style
  • Added formatting and linting commands to the new package.json
  • Added comprehensive .gitignore for node_modules
  • Created detailed README with usage instructions

CMake Fixes

  • Fixed incorrect DEPENDS usage in add_custom_command(TARGET ...)
  • Improved cross-platform build detection
  • Enhanced variable scope handling in CMake functions

📁 New Files

  • package.json - Node.js dependencies and scripts
  • eslint.config.js - ESLint configuration
  • .prettierrc - Prettier formatting rules
  • .gitignore - Git ignore for build artifacts
  • README.md - Documentation for build scripts
  • HermesWindows.cmake - Centralized Windows build logic

🎯 Benefits

  • Security: Resolves BinSkim security compliance issues
  • Maintainability: Centralized Windows build configuration reduces duplication
  • Developer Experience: Better build script formatting and selective target building
  • Reliability: Fixed various build system edge cases and warnings

✅ Testing

  • Verified builds for x64, ARM64, and ARM64EC architectures
  • Confirmed UWP and Win32 build scenarios
  • Validated security flag application across different configurations
  • Tested JavaScript linting and formatting workflows
Microsoft Reviewers: Open in CodeFlow

@vmoroz vmoroz requested a review from a team as a code owner July 13, 2025 04:56
@vmoroz vmoroz changed the title Build improvements (DRAFT) Build improvements Jul 14, 2025
@vmoroz vmoroz force-pushed the PR/build_improve branch 2 times, most recently from 62bfd7a to bd3c17b Compare July 21, 2025 21:05
@vmoroz vmoroz changed the title (DRAFT) Build improvements Build improvements and fix BinSkim/security issues Jul 21, 2025
@vmoroz vmoroz force-pushed the PR/build_improve branch from bd3c17b to 37028ba Compare July 21, 2025 21:56
@vmoroz vmoroz enabled auto-merge (squash) July 21, 2025 22:34
@vmoroz vmoroz merged commit eda7aef into microsoft:main Jul 21, 2025
12 checks passed
@vmoroz vmoroz deleted the PR/build_improve branch July 22, 2025 02:19
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