Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
080845b
Fix Envoy build on Windows
anuraaga Dec 15, 2025
6fcbc41
Remove redundant move
anuraaga Dec 18, 2025
8b02976
Lints
anuraaga Dec 18, 2025
cd0e20d
Simplify cel-cpp patch
anuraaga Dec 19, 2025
d42ba51
Simplify protoconverter patch
anuraaga Dec 19, 2025
e0bfb72
Move script to windows folder
anuraaga Dec 19, 2025
4d1fee3
Simplify luajit patch
anuraaga Dec 19, 2025
2ce46e6
Formatting
anuraaga Dec 19, 2025
e05b8fd
Preserve trailing whitespace
anuraaga Dec 19, 2025
f1dc4f8
luajit incremental link
anuraaga Dec 19, 2025
db16aa1
Remove leftover rule
anuraaga Dec 19, 2025
7e8341b
Merge branch 'main' of https://github.com/envoyproxy/envoy into fix-w…
anuraaga Dec 20, 2025
ec35983
Merge branch 'main' of https://github.com/envoyproxy/envoy into fix-w…
anuraaga Jan 6, 2026
c6f5fc6
Add network filter to dep allowlist.
anuraaga Jan 6, 2026
e04dab6
Separate windows patches
anuraaga Jan 7, 2026
3766659
Cleanup containers.bzl
anuraaga Jan 7, 2026
95bb385
Formatting
anuraaga Jan 7, 2026
a60d4d5
Restore luajit compile flags
anuraaga Jan 7, 2026
0774afa
Merge branch 'main' of https://github.com/envoyproxy/envoy into fix-w…
anuraaga Jan 12, 2026
d94d500
Filter reverse_tunnel from windows build
anuraaga Jan 12, 2026
e8b89e6
Revert reverse_tunnel
anuraaga Jan 12, 2026
f1c99d2
More extensions
anuraaga Jan 12, 2026
b1e4e71
Remove mapping RECVTOS to ECN on Windows
anuraaga Jan 12, 2026
646541d
More extensions
anuraaga Jan 12, 2026
a778915
more filter
anuraaga Jan 12, 2026
fe412a0
Disable clusters.reverse_connection
anuraaga Jan 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ genrule(
stamp = 1,
)

# For Windows, which must list each exported symbol individually.
genrule(
name = "exported_symbols_windows",
srcs = ["//source/extensions/dynamic_modules:abi.h"],
outs = ["exported_symbols_windows.def"],
cmd = "$(location //tools/windows:gen_dynamic_modules_exports) $(location //source/extensions/dynamic_modules:abi.h) $@",
tools = ["//tools/windows:gen_dynamic_modules_exports"],
)

cc_library(
name = "static_stdlib",
linkopts = select({
Expand Down
29 changes: 29 additions & 0 deletions bazel/com_google_protoconverter_win.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/build_defs/BUILD.bazel b/build_defs/BUILD.bazel
index 732514d..a6be18b 100644
--- a/build_defs/BUILD.bazel
+++ b/build_defs/BUILD.bazel
@@ -13,10 +13,23 @@ package(
)

create_compiler_config_setting(
- name = "config_msvc",
+ name = "config_msvc_cl",
value = "msvc-cl",
)

+create_compiler_config_setting(
+ name = "config_clang_cl",
+ value = "clang-cl",
+)
+
+selects.config_setting_group(
+ name = "config_msvc",
+ match_any = [
+ ":config_clang_cl",
+ ":config_msvc_cl",
+ ],
+)
+
config_setting(
name = "aarch64",
values = {"cpu": "linux-aarch_64"},
8 changes: 7 additions & 1 deletion bazel/envoy_internal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ def envoy_exported_symbols_input():
return [
"@envoy//bazel:exported_symbols.txt",
"@envoy//bazel:exported_symbols_apple.txt",
]
] + select({
"@envoy//bazel:windows_x86_64": ["//bazel:exported_symbols_windows.def"],
"//conditions:default": [],
})

# Default symbols to be exported.
def _envoy_default_exported_symbols():
Expand All @@ -240,6 +243,9 @@ def _envoy_default_exported_symbols():
"@envoy//bazel:apple": [
"-Wl,-exported_symbols_list,$(location @envoy//bazel:exported_symbols_apple.txt)",
],
"@envoy//bazel:windows_x86_64": [
"-DEF:$(location //bazel:exported_symbols_windows.def)",
],
"//conditions:default": [],
})

Expand Down
5 changes: 4 additions & 1 deletion bazel/external/zstd.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ cc_library(
"lib/zstd_errors.h",
],
includes = ["lib"],
linkopts = ["-pthread"],
linkopts = select({
"@platforms//os:windows": [],
"//conditions:default": ["-pthread"],
}),
linkstatic = True,
local_defines = [
"XXH_NAMESPACE=ZSTD_",
Expand Down
29 changes: 28 additions & 1 deletion bazel/foreign_cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ configure_make(
"nocompdb",
"skip_on_windows",
],
target_compatible_with = ["@platforms//os:linux"],
targets = ["install"],
)

Expand Down Expand Up @@ -103,7 +104,10 @@ cc_library(

configure_make(
name = "luajit",
configure_command = "luajit_build.sh",
configure_command = select({
"//bazel:windows_x86_64": "luajit_build_win.sh",
"//conditions:default": "luajit_build.sh",
}),
env = select({
# This shouldn't be needed! See
# https://github.com/envoyproxy/envoy/issues/6084
Expand Down Expand Up @@ -404,6 +408,29 @@ envoy_cmake(
tags = ["skip_on_windows"],
)

configure_make(
name = "dlfcn_win32_build",
configure_in_place = True,
configure_options = [
"--disable-shared",
"--enable-static",
],
lib_source = "@com_github_dlfcn_win32//:all",
out_static_libs = select({
"//bazel:windows_x86_64": ["libdl.a"],
"//conditions:default": [],
}),
target_compatible_with = ["@platforms//os:windows"],
)

cc_library(
name = "dlfcn_win32",
deps = select({
"//bazel:windows_x86_64": [":dlfcn_win32_build"],
"//conditions:default": [],
}),
)

envoy_cmake(
name = "maxmind",
build_args = select({
Expand Down
63 changes: 63 additions & 0 deletions bazel/foreign_cc/luajit_win.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
diff --git a/luajit_build_win.sh b/luajit_build_win.sh
new file mode 100755
index 00000000..c6267893
--- /dev/null
+++ b/luajit_build_win.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+set -e
+
+PREFIX=""
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ --prefix=*)
+ PREFIX="${1#*=}"
+ shift
+ ;;
+ --prefix)
+ PREFIX="$2"
+ shift 2
+ ;;
+ *)
+ shift
+ ;;
+ esac
+done
+
+# Copy source tree to a build directory
+SRC_DIR="$(dirname "$(realpath "$0")")"
+BUILD_DIR="$(basename "$SRC_DIR")"
+cp -r "$SRC_DIR" "$BUILD_DIR"
+cd "$BUILD_DIR"
+
+cd src
+./msvcbuild.bat static
+
+mkdir -p "$PREFIX/lib"
+cp lua51.lib "$PREFIX/lib"
+mkdir -p "$PREFIX/include/luajit-2.1"
+for header in lauxlib.h luaconf.h lua.h lua.hpp luajit.h lualib.h; do
+ cp "$header" "$PREFIX/include/luajit-2.1"
+done
+mkdir -p "$PREFIX/bin"
+cp luajit.exe "$PREFIX/bin"
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index d6aed170..42604601 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -18,9 +18,11 @@
@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_ASSERT
@set DEBUGCFLAGS=
@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
-@set LJDYNBUILD=/DLUA_BUILD_AS_DLL /MD
-@set LJDYNBUILD_DEBUG=/DLUA_BUILD_AS_DLL /MDd
-@set LJCOMPILETARGET=/Zi
+@rem Use MT to match flags set by bazel for static build
+@set LJDYNBUILD=/DLUA_BUILD_AS_DLL /MT
+@set LJDYNBUILD_DEBUG=/DLUA_BUILD_AS_DLL /MTd
+@rem Avoid incremental link which doesn't work with bazel's deletion of intermediate files
+@set LJCOMPILETARGET=/Z7
@set LJLINKTYPE=/DEBUG /RELEASE
@set LJLINKTYPE_DEBUG=/DEBUG
@set LJLINKTARGET=/OPT:REF /OPT:ICF /INCREMENTAL:NO
Comment on lines +50 to +63
Copy link
Member

Choose a reason for hiding this comment

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

If we need additional patch for these extensions (lua, protocolconverter related) works, could we just compile it out rather then add additional patches?

9 changes: 9 additions & 0 deletions bazel/platforms/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,12 @@ platform(
"@platforms//os:macos",
],
)

platform(
name = "x64_windows-clang-cl",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
"@bazel_tools//tools/cpp:clang-cl",
],
)
54 changes: 37 additions & 17 deletions bazel/repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,45 @@ def _envoy_repo_impl(repository_ctx):

"""

# parse container information for use in RBE
json_result = repository_ctx.execute([
repository_ctx.path(repository_ctx.attr.yq),
repository_ctx.path(repository_ctx.attr.envoy_ci_config),
"-ojson",
])
if json_result.return_code != 0:
fail("yq failed: {}".format(json_result.stderr))
repository_ctx.file("ci-config.json", json_result.stdout)
config_data = json.decode(repository_ctx.read("ci-config.json"))
repo = ""
repo_gcr = ""
sha = ""
sha_gcc = ""
sha_mobile = ""
sha_worker = ""
tag = ""

# yq via bazel doesn't work on Windows, but we don't need the real flag_values
# there either. For this and other reasons, ideally we could parse YAML directly.
# https://github.com/bazelbuild/bazel/issues/24766
if repository_ctx.os.name.lower().find("windows") == -1:
json_result = repository_ctx.execute([
repository_ctx.path(repository_ctx.attr.yq),
repository_ctx.path(repository_ctx.attr.envoy_ci_config),
"-ojson",
])
if json_result.return_code != 0:
fail("yq failed: {}".format(json_result.stderr))
repository_ctx.file("ci-config.json", json_result.stdout)
config_data = json.decode(repository_ctx.read("ci-config.json"))
repo = config_data["build-image"]["repo"]
repo_gcr = config_data["build-image"]["repo-gcr"]
sha = config_data["build-image"]["sha"]
sha_gcc = config_data["build-image"]["sha-gcc"]
sha_mobile = config_data["build-image"]["sha-mobile"]
sha_worker = config_data["build-image"]["sha-worker"]
tag = config_data["build-image"]["tag"]

repository_ctx.file("containers.bzl", CONTAINERS.format(
repo = config_data["build-image"]["repo"],
repo_gcr = config_data["build-image"]["repo-gcr"],
sha = config_data["build-image"]["sha"],
sha_gcc = config_data["build-image"]["sha-gcc"],
sha_mobile = config_data["build-image"]["sha-mobile"],
sha_worker = config_data["build-image"]["sha-worker"],
tag = config_data["build-image"]["tag"],
repo = repo,
repo_gcr = repo_gcr,
sha = sha,
sha_gcc = sha_gcc,
sha_mobile = sha_mobile,
sha_worker = sha_worker,
tag = tag,
))

repo_version_path = repository_ctx.path(repository_ctx.attr.envoy_version)
api_version_path = repository_ctx.path(repository_ctx.attr.envoy_api_version)
version = repository_ctx.read(repo_version_path).strip()
Expand Down
24 changes: 22 additions & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ WINDOWS_SKIP_TARGETS = [
"envoy.filters.http.sxg",
"envoy.tracers.dynamic_ot",
"envoy.tracers.datadog",
# Only implemented for Linux.
"envoy.resource_monitors.cpu_utilization",
# Extensions that require CEL.
"envoy.access_loggers.extension_filters.cel",
"envoy.rate_limit_descriptors.expr",
Expand All @@ -31,6 +33,11 @@ WINDOWS_SKIP_TARGETS = [
"envoy.filters.http.rbac",
"envoy.filters.network.rbac",
"envoy.rbac.matchers.upstream_ip_port",
# Very new and likely not useful on Windows
"envoy.bootstrap.reverse_tunnel.downstream_socket_interface",
"envoy.bootstrap.reverse_tunnel.upstream_socket_interface",
"envoy.clusters.reverse_connection",
"envoy.resolvers.reverse_connection",
]

NO_HTTP3_SKIP_TARGETS = [
Expand Down Expand Up @@ -82,7 +89,10 @@ def _cc_deps():
external_http_archive(
name = "com_google_protoconverter",
patch_args = ["-p1"],
patches = ["@envoy//bazel:com_google_protoconverter.patch"],
patches = [
"@envoy//bazel:com_google_protoconverter.patch",
"@envoy//bazel:com_google_protoconverter_win.patch",
],
patch_cmds = [
"rm src/google/protobuf/stubs/common.cc",
"rm src/google/protobuf/stubs/common.h",
Expand Down Expand Up @@ -218,6 +228,7 @@ def envoy_dependencies(skip_targets = []):
)
external_http_archive("envoy_toolshed")

_com_github_dlfcn_win32()
_com_github_maxmind_libmaxminddb()
_thrift()

Expand Down Expand Up @@ -807,7 +818,10 @@ def _com_github_luajit_luajit():
external_http_archive(
name = "com_github_luajit_luajit",
build_file_content = BUILD_ALL_CONTENT,
patches = ["@envoy//bazel/foreign_cc:luajit.patch"],
patches = [
"@envoy//bazel/foreign_cc:luajit.patch",
"@envoy//bazel/foreign_cc:luajit_win.patch",
],
patch_args = ["-p1"],
)

Expand Down Expand Up @@ -934,3 +948,9 @@ def _com_github_maxmind_libmaxminddb():
name = "com_github_maxmind_libmaxminddb",
build_file_content = BUILD_ALL_CONTENT,
)

def _com_github_dlfcn_win32():
external_http_archive(
name = "com_github_dlfcn_win32",
build_file_content = BUILD_ALL_CONTENT,
)
21 changes: 21 additions & 0 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,27 @@ REPOSITORY_LOCATIONS_SPEC = dict(
license = "Apache-2.0",
license_url = "https://github.com/bazelbuild/rules_license/blob/{version}/LICENSE",
),
com_github_dlfcn_win32 = dict(
project_name = "dlfcn-win32",
project_desc = "An implementation of dlfcn for Windows.",
project_url = "https://github.com/dlfcn-win32/dlfcn-win32",
version = "1.4.2",
sha256 = "f61a874bc9163ab488accb364fd681d109870c86e8071f4710cbcdcbaf9f2565",
strip_prefix = "dlfcn-win32-{version}",
urls = ["https://github.com/dlfcn-win32/dlfcn-win32/archive/refs/tags/v{version}.tar.gz"],
use_category = ["dataplane_ext"],
extensions = [
"envoy.access_loggers.dynamic_modules",
"envoy.filters.http.dynamic_modules",
"envoy.filters.listener.dynamic_modules",
"envoy.filters.network.dynamic_modules",
"envoy.filters.udp_listener.dynamic_modules",
],
release_date = "2025-03-04",
cpe = "N/A",
license = "MIT",
license_url = "https://github.com/dlfcn-win32/dlfcn-win32/blob/v{version}/COPYING",
),
com_github_maxmind_libmaxminddb = dict(
project_name = "maxmind_libmaxminddb",
project_desc = "C library for reading MaxMind DB files",
Expand Down
11 changes: 11 additions & 0 deletions envoy/api/os_sys_calls.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#pragma once

#ifndef _WIN32
#include <sys/resource.h>

#endif
#include <sys/stat.h>

#include <chrono>
Expand All @@ -13,6 +16,14 @@
#include "envoy/common/pure.h"
#include "envoy/network/address.h"

#ifdef _WIN32
struct rlimit {
int rlim_cur;
int rlim_max;
};
#define RLIMIT_NOFILE 7
#endif // _WIN32

namespace Envoy {
namespace Api {

Expand Down
Loading
Loading