From 55996cf9c3294d7b7d8474188f3d3a0cb73e4a38 Mon Sep 17 00:00:00 2001 From: Jiayi Weng Date: Thu, 20 Jan 2022 15:40:20 -0500 Subject: [PATCH] force apply glibc-2.17 to vizdoom binary (#54) --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- Makefile | 2 +- envpool/make_test.py | 2 + envpool/vizdoom/BUILD | 15 ++---- envpool/vizdoom/bin/BUILD | 25 ++++++++++ envpool/workspace0.bzl | 11 ++++ third_party/glibc_version_header/BUILD | 0 .../glibc_version_header.BUILD | 5 ++ third_party/vizdoom/vizdoom.BUILD | 50 ++++++++++++++++--- 10 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 envpool/vizdoom/bin/BUILD create mode 100644 third_party/glibc_version_header/BUILD create mode 100644 third_party/glibc_version_header/glibc_version_header.BUILD diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 37d9af8a..aebe346c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: release: - runs-on: [self-hosted, Linux, X64, Wheel] + runs-on: ${{ matrix.python-version }} strategy: matrix: python-version: [3.7, 3.8, 3.9] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 26becc25..77ee571e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: test: - runs-on: [self-hosted, Linux, X64] + runs-on: [self-hosted, Linux, X64, Test] steps: - name: Cancel previous run uses: styfle/cancel-workflow-action@0.9.1 diff --git a/Makefile b/Makefile index 688109f0..3924c037 100644 --- a/Makefile +++ b/Makefile @@ -129,7 +129,7 @@ docker-release: docker run --network=host -v `pwd`/wheelhouse:/whl -it $(PROJECT_NAME)-release:$(COMMIT_HASH) bash -c "cp wheelhouse/* /whl" echo successfully build docker image with tag $(PROJECT_NAME)-release:$(COMMIT_HASH) -pypi-wheel: bazel-clean auditwheel-install bazel-build +pypi-wheel: auditwheel-install bazel-build ls dist/*.whl | xargs auditwheel repair --plat manylinux_2_17_x86_64 release-test1: diff --git a/envpool/make_test.py b/envpool/make_test.py index 95fc5650..c8332a0a 100644 --- a/envpool/make_test.py +++ b/envpool/make_test.py @@ -44,6 +44,8 @@ def test_make_atari(self) -> None: self.assertEqual(env_dm.action_spec().num_values, 18) def test_make_vizdoom(self) -> None: + spec = envpool.make_spec("MyWayHome-v1") + print(spec) env = envpool.make_gym("MyWayHome-v1") print(env) self.assertIsInstance(env, gym.Env) diff --git a/envpool/vizdoom/BUILD b/envpool/vizdoom/BUILD index 2e8e79a7..aa8e11d8 100644 --- a/envpool/vizdoom/BUILD +++ b/envpool/vizdoom/BUILD @@ -25,17 +25,6 @@ genrule( cmd = "mkdir -p $(OUTS) && cp $(SRCS) $(OUTS)", ) -genrule( - name = "gen_vizdoom_exe", - srcs = [ - "@vizdoom", - "@vizdoom//:vizdoom_pk3", - "@freedoom", - ], - outs = ["bin"], - cmd = "mkdir -p $(OUTS) && cp $(SRCS) $(OUTS)", -) - cc_library( name = "utils", hdrs = ["utils.h"], @@ -68,7 +57,9 @@ py_library( name = "vizdoom", srcs = ["__init__.py"], data = [ - ":gen_vizdoom_exe", + "//envpool/vizdoom/bin:vizdoom_bin", + "//envpool/vizdoom/bin:vizdoom_pk3", + "//envpool/vizdoom/bin:freedoom", ":gen_vizdoom_maps", ":vizdoom_envpool.so", ], diff --git a/envpool/vizdoom/bin/BUILD b/envpool/vizdoom/bin/BUILD new file mode 100644 index 00000000..5277f88b --- /dev/null +++ b/envpool/vizdoom/bin/BUILD @@ -0,0 +1,25 @@ +package(default_visibility = ["//visibility:public"]) + +genrule( + name = "vizdoom_bin", + srcs = ["@vizdoom//:vizdoom"], + outs = ["vizdoom"], + cmd = "cp $< $@", + executable = True, +) + +genrule( + name = "vizdoom_pk3", + srcs = ["@vizdoom//:vizdoom_pk3"], + outs = ["vizdoom.pk3"], + cmd = "cp $< $@", + executable = True, +) + +genrule( + name = "freedoom", + srcs = ["@freedoom"], + outs = ["freedoom2.wad"], + cmd = "cp $< $@", + executable = True, +) diff --git a/envpool/workspace0.bzl b/envpool/workspace0.bzl index 21f6378c..2883ef79 100644 --- a/envpool/workspace0.bzl +++ b/envpool/workspace0.bzl @@ -94,6 +94,17 @@ def workspace(): ], ) + maybe( + http_archive, + name = "glibc_version_header", + sha256 = "57db74f933b7a9ea5c653498640431ce0e52aaef190d6bb586711ec4f8aa2b9e", + strip_prefix = "glibc_version_header-0.1/version_headers/", + urls = [ + "https://github.com/wheybags/glibc_version_header/archive/refs/tags/0.1.tar.gz", + ], + build_file = "//third_party/glibc_version_header:glibc_version_header.BUILD", + ) + maybe( http_archive, name = "concurrentqueue", diff --git a/third_party/glibc_version_header/BUILD b/third_party/glibc_version_header/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/glibc_version_header/glibc_version_header.BUILD b/third_party/glibc_version_header/glibc_version_header.BUILD new file mode 100644 index 00000000..0312e669 --- /dev/null +++ b/third_party/glibc_version_header/glibc_version_header.BUILD @@ -0,0 +1,5 @@ +filegroup( + name = "glibc_2_17", + srcs = ["force_link_glibc_2.17.h"], + visibility = ["//visibility:public"], +) diff --git a/third_party/vizdoom/vizdoom.BUILD b/third_party/vizdoom/vizdoom.BUILD index 3e7229bd..dd77e00b 100644 --- a/third_party/vizdoom/vizdoom.BUILD +++ b/third_party/vizdoom/vizdoom.BUILD @@ -2,7 +2,13 @@ load("@envpool//third_party:common.bzl", "template_rule") cc_binary( name = "arithchk", - srcs = ["gdtoa/arithchk.c"], + srcs = [ + "gdtoa/arithchk.c", + "@glibc_version_header//:glibc_2_17", + ], + copts = [ + "-include $(execpath @glibc_version_header//:glibc_2_17)", + ], ) genrule( @@ -18,6 +24,10 @@ cc_binary( srcs = [ "gdtoa/qnan.c", ":arith.h", + "@glibc_version_header//:glibc_2_17", + ], + copts = [ + "-include $(execpath @glibc_version_header//:glibc_2_17)", ], ) @@ -37,6 +47,7 @@ cc_library( "gdtoa/misc.c", ":arith.h", ":gd_qnan.h", + "@glibc_version_header//:glibc_2_17", ], hdrs = glob(["gdtoa/*.h"]), copts = [ @@ -44,6 +55,7 @@ cc_library( "-Wextra", "-DINFNAN_CHECK", "-DMULTIPLE_THREADS", + "-include $(execpath @glibc_version_header//:glibc_2_17)", ], strip_include_prefix = "gdtoa", ) @@ -58,6 +70,7 @@ cc_library( "bzip2/decompress.c", "bzip2/huffman.c", "bzip2/randtable.c", + "@glibc_version_header//:glibc_2_17", ], hdrs = glob([ "bzip2/*.h", @@ -67,6 +80,7 @@ cc_library( "-Wall", "-Wextra", "-fomit-frame-pointer", + "-include $(execpath @glibc_version_header//:glibc_2_17)", ], strip_include_prefix = "bzip2", ) @@ -91,7 +105,9 @@ cc_library( "lzma/C/Threads.c", "lzma/C/LzFindMt.c", ], - ), + ) + [ + "@glibc_version_header//:glibc_2_17", + ], hdrs = glob( [ "lzma/C/*.h", @@ -107,6 +123,7 @@ cc_library( "-Wextra", "-fomit-frame-pointer", "-D_7ZIP_PPMD_SUPPPORT", + "-include $(execpath @glibc_version_header//:glibc_2_17)", ], strip_include_prefix = "lzma/C", ) @@ -123,15 +140,23 @@ cc_binary( "tools/re2c/scanner.cc", "tools/re2c/substr.cc", "tools/re2c/translate.cc", + "@glibc_version_header//:glibc_2_17", ] + glob(["tools/re2c/*.h"]), copts = [ "-DHAVE_CONFIG_H", + "-include $(execpath @glibc_version_header//:glibc_2_17)", ], ) cc_binary( name = "lemon", - srcs = ["tools/lemon/lemon.c"], + srcs = [ + "tools/lemon/lemon.c", + "@glibc_version_header//:glibc_2_17", + ], + copts = [ + "-include $(execpath @glibc_version_header//:glibc_2_17)", + ], ) genrule( @@ -177,7 +202,9 @@ cc_library( "dumb/**/*.h", "dumb/**/*.c", "dumb/**/*.inc", - ]), + ]) + [ + "@glibc_version_header//:glibc_2_17", + ], hdrs = glob([ "dumb/include/*.h", ]), @@ -187,6 +214,7 @@ cc_library( "-Wno-pointer-sign", "-Wno-uninitialized", "-Wno-unused-but-set-variable", + "-include $(execpath @glibc_version_header//:glibc_2_17)", ], includes = [ "dumb/include", @@ -198,7 +226,9 @@ cc_library( srcs = glob([ "game-music-emu/gme/*.cpp", "game-music-emu/gme/*.h", - ]), + ]) + [ + "@glibc_version_header//:glibc_2_17", + ], hdrs = [ "game-music-emu/gme/gme.h", ], @@ -206,6 +236,7 @@ cc_library( "-DLIBGME_VISIBILITY", "-fvisibility=hidden", "-fvisibility-inlines-hidden", + "-include $(execpath @glibc_version_header//:glibc_2_17)", ], strip_include_prefix = "game-music-emu", ) @@ -300,12 +331,14 @@ cc_library( "src/*.h", ]) + [ "src/oplsynth/fmopl.cpp", + "@glibc_version_header//:glibc_2_17", ], copts = [ "-Dstricmp=strcasecmp", "-Dstrnicmp=strncasecmp", "-fno-tree-dominator-opts", "-fno-tree-fre", + "-include $(execpath @glibc_version_header//:glibc_2_17)", ], includes = [ "src", @@ -316,12 +349,16 @@ cc_binary( name = "zipdir", srcs = [ "tools/zipdir/zipdir.c", + "@glibc_version_header//:glibc_2_17", ], deps = [ ":bzip2", ":lzma", "@zlib", ], + copts = [ + "-include $(execpath @glibc_version_header//:glibc_2_17)", + ], ) filegroup( @@ -688,6 +725,7 @@ cc_binary( "src/viz_message_queue.cpp", "src/viz_shared_memory.cpp", "src/viz_system.cpp", + "@glibc_version_header//:glibc_2_17", ], copts = [ "-Dstricmp=strcasecmp", @@ -695,7 +733,6 @@ cc_binary( "-DNO_GTK=1", "-DNO_FMOD=1", "-DNO_OPENAL=1", - "-std=c++11", "-fPIC", "-fomit-frame-pointer", "-D__forceinline=inline", @@ -715,6 +752,7 @@ cc_binary( "-msse", "-msse2", "-mmmx", + "-include $(execpath @glibc_version_header//:glibc_2_17)", ], data = [ ":vizdoom_pk3",