You are not logged in.

#1 2021-04-24 19:58:07

loqs
Member
Registered: 2014-03-06
Posts: 17,327

godot's lack of PIE

godot 3.3-1 is built without pie which is unusal as pie is enabled by default in Arch's gcc.  So it must be being disabled explicitly.
Which it is [1].  The commit leads to pull request [2].  Which has two reasons for the change:

  • Miss-detection in some file managers of the binary as a library.

  • Incompatibility with dynamic module loading. [3]

The former does not to me justify such a change which can not be altered at build time.
The latter seems a surprising incompatibility to me.  So I reverted the change.
I also unbundled all dependencies Arch ships that had not been customized.  This required five additional patches.
See PKGBUILD.diff below.  The modified built package passed namcap's pie detection.  It dynamically loads ALSA and pulse and can play audio.
This would seem to demonstrate pie and the dynamic loading approach godot is using are not incompatible.

Is there some flaw in my reasoning,  I am missing?

diff --git a/trunk/0001-CPU-lightmapper-environment-energy-fixes.patch b/trunk/0001-CPU-lightmapper-environment-energy-fixes.patch
new file mode 100644
index 0000000..3856ec2
--- /dev/null
+++ b/trunk/0001-CPU-lightmapper-environment-energy-fixes.patch
@@ -0,0 +1,177 @@
+From 33d6b1f68f807e0d25430c269f4c34e134bbdfa4 Mon Sep 17 00:00:00 2001
+From: JFonS <joan.fonssanchez@gmail.com>
+Date: Thu, 22 Apr 2021 15:01:25 +0200
+Subject: [PATCH] CPU lightmapper environment energy fixes.
+
+* Better handling of the scene's environment energy in the lightmapper
+  bakes.
+* Fixed a bug where ProceduralSky::get_panorama() returned a reference
+  instead of a copy.
+* Removed includes to Embree's internal header files.
+
+(cherry picked from commit 2db2d1153d2deb8490c0ca5ad0f094077f382f28)
+---
+ modules/raycast/lightmap_raycaster.cpp | 30 +++++++++++---------------
+ scene/3d/baked_lightmap.cpp            | 19 ++++++++++++----
+ scene/3d/baked_lightmap.h              |  2 +-
+ scene/resources/sky.cpp                |  4 ++--
+ scene/resources/sky.h                  |  2 +-
+ 5 files changed, 31 insertions(+), 26 deletions(-)
+
+diff --git a/modules/raycast/lightmap_raycaster.cpp b/modules/raycast/lightmap_raycaster.cpp
+index 29334b7cb0..fac4385d77 100644
+--- a/modules/raycast/lightmap_raycaster.cpp
++++ b/modules/raycast/lightmap_raycaster.cpp
+@@ -30,12 +30,7 @@
+ 
+ #include "lightmap_raycaster.h"
+ 
+-// From Embree.
+-#include <math/vec2.h>
+-#include <math/vec3.h>
+-#include <xmmintrin.h>
+-
+-using namespace embree;
++#include <pmmintrin.h>
+ 
+ LightmapRaycaster *LightmapRaycasterEmbree::create_embree_raycaster() {
+ 	return memnew(LightmapRaycasterEmbree);
+@@ -135,25 +130,24 @@ void LightmapRaycasterEmbree::add_mesh(const Vector<Vector3> &p_vertices, const
+ 
+ 	ERR_FAIL_COND(vertex_count % 3 != 0);
+ 	ERR_FAIL_COND(vertex_count != p_uv2s.size());
++	ERR_FAIL_COND(!p_normals.empty() && vertex_count != p_normals.size());
+ 
+-	Vec3fa *embree_vertices = (Vec3fa *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, sizeof(Vec3fa), vertex_count);
+-	Vec2fa *embree_light_uvs = (Vec2fa *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE, 0, RTC_FORMAT_FLOAT2, sizeof(Vec2fa), vertex_count);
+-	uint32_t *embree_triangles = (uint32_t *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, sizeof(uint32_t) * 3, vertex_count / 3);
++	Vector3 *embree_vertices = (Vector3 *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, sizeof(Vector3), vertex_count);
++	copymem(embree_vertices, p_vertices.ptr(), sizeof(Vector3) * vertex_count);
+ 
+-	Vec3fa *embree_normals = nullptr;
+-	if (!p_normals.empty()) {
+-		embree_normals = (Vec3fa *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE, 1, RTC_FORMAT_FLOAT3, sizeof(Vec3fa), vertex_count);
+-	}
++	Vector2 *embree_light_uvs = (Vector2 *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE, 0, RTC_FORMAT_FLOAT2, sizeof(Vector2), vertex_count);
++	copymem(embree_light_uvs, p_uv2s.ptr(), sizeof(Vector2) * vertex_count);
+ 
++	uint32_t *embree_triangles = (uint32_t *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, sizeof(uint32_t) * 3, vertex_count / 3);
+ 	for (int i = 0; i < vertex_count; i++) {
+-		embree_vertices[i] = Vec3fa(p_vertices[i].x, p_vertices[i].y, p_vertices[i].z);
+-		embree_light_uvs[i] = Vec2fa(p_uv2s[i].x, p_uv2s[i].y);
+-		if (embree_normals != nullptr) {
+-			embree_normals[i] = Vec3fa(p_normals[i].x, p_normals[i].y, p_normals[i].z);
+-		}
+ 		embree_triangles[i] = i;
+ 	}
+ 
++	if (!p_normals.empty()) {
++		Vector3 *embree_normals = (Vector3 *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE, 1, RTC_FORMAT_FLOAT3, sizeof(Vector3), vertex_count);
++		copymem(embree_normals, p_normals.ptr(), sizeof(Vector3) * vertex_count);
++	}
++
+ 	rtcCommitGeometry(embree_mesh);
+ 	rtcSetGeometryIntersectFilterFunction(embree_mesh, filter_function);
+ 	rtcSetGeometryUserData(embree_mesh, this);
+diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
+index 67c201c3e5..af044fccdb 100644
+--- a/scene/3d/baked_lightmap.cpp
++++ b/scene/3d/baked_lightmap.cpp
+@@ -810,7 +810,7 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_data_sa
+ 			} break;
+ 			case ENVIRONMENT_MODE_CUSTOM_SKY: {
+ 				if (environment_custom_sky.is_valid()) {
+-					environment_image = _get_irradiance_from_sky(environment_custom_sky, Vector2i(128, 64));
++					environment_image = _get_irradiance_from_sky(environment_custom_sky, environment_custom_energy, Vector2i(128, 64));
+ 					environment_xform.set_euler(environment_custom_sky_rotation_degrees * Math_PI / 180.0);
+ 				}
+ 
+@@ -1233,7 +1233,7 @@ void BakedLightmap::_clear_lightmaps() {
+ 	}
+ }
+ 
+-Ref<Image> BakedLightmap::_get_irradiance_from_sky(Ref<Sky> p_sky, Vector2i p_size) {
++Ref<Image> BakedLightmap::_get_irradiance_from_sky(Ref<Sky> p_sky, float p_energy, Vector2i p_size) {
+ 	if (p_sky.is_null()) {
+ 		return Ref<Image>();
+ 	}
+@@ -1245,7 +1245,7 @@ Ref<Image> BakedLightmap::_get_irradiance_from_sky(Ref<Sky> p_sky, Vector2i p_si
+ 	}
+ 	Ref<ProceduralSky> procedural = p_sky;
+ 	if (procedural.is_valid()) {
+-		sky_image = procedural->get_panorama();
++		sky_image = procedural->get_data();
+ 	}
+ 
+ 	if (sky_image.is_null()) {
+@@ -1254,6 +1254,17 @@ Ref<Image> BakedLightmap::_get_irradiance_from_sky(Ref<Sky> p_sky, Vector2i p_si
+ 
+ 	sky_image->convert(Image::FORMAT_RGBF);
+ 	sky_image->resize(p_size.x, p_size.y, Image::INTERPOLATE_CUBIC);
++
++	if (p_energy != 1.0) {
++		sky_image->lock();
++		for (int i = 0; i < p_size.y; i++) {
++			for (int j = 0; j < p_size.x; j++) {
++				sky_image->set_pixel(j, i, sky_image->get_pixel(j, i) * p_energy);
++			}
++		}
++		sky_image->unlock();
++	}
++
+ 	return sky_image;
+ }
+ 
+@@ -1261,7 +1272,7 @@ Ref<Image> BakedLightmap::_get_irradiance_map(Ref<Environment> p_env, Vector2i p
+ 	Environment::BGMode bg_mode = p_env->get_background();
+ 	switch (bg_mode) {
+ 		case Environment::BG_SKY: {
+-			return _get_irradiance_from_sky(p_env->get_sky(), Vector2i(128, 64));
++			return _get_irradiance_from_sky(p_env->get_sky(), p_env->get_bg_energy(), Vector2i(128, 64));
+ 		}
+ 		case Environment::BG_CLEAR_COLOR:
+ 		case Environment::BG_COLOR: {
+diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h
+index 6f8f0b8f98..09791b5d2a 100644
+--- a/scene/3d/baked_lightmap.h
++++ b/scene/3d/baked_lightmap.h
+@@ -187,7 +187,7 @@ private:
+ 	void _clear_lightmaps();
+ 
+ 	void _get_material_images(const MeshesFound &p_found_mesh, Lightmapper::MeshData &r_mesh_data, Vector<Ref<Texture> > &r_albedo_textures, Vector<Ref<Texture> > &r_emission_textures);
+-	Ref<Image> _get_irradiance_from_sky(Ref<Sky> p_sky, Vector2i p_size);
++	Ref<Image> _get_irradiance_from_sky(Ref<Sky> p_sky, float p_energy, Vector2i p_size);
+ 	Ref<Image> _get_irradiance_map(Ref<Environment> p_env, Vector2i p_size);
+ 	void _find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound> &meshes, Vector<LightsFound> &lights);
+ 	Vector2i _compute_lightmap_size(const MeshesFound &p_mesh);
+diff --git a/scene/resources/sky.cpp b/scene/resources/sky.cpp
+index 0db92f2132..0bad4a2ed0 100644
+--- a/scene/resources/sky.cpp
++++ b/scene/resources/sky.cpp
+@@ -390,8 +390,8 @@ ProceduralSky::TextureSize ProceduralSky::get_texture_size() const {
+ 	return texture_size;
+ }
+ 
+-Ref<Image> ProceduralSky::get_panorama() const {
+-	return panorama;
++Ref<Image> ProceduralSky::get_data() const {
++	return panorama->duplicate();
+ }
+ 
+ RID ProceduralSky::get_rid() const {
+diff --git a/scene/resources/sky.h b/scene/resources/sky.h
+index 5b5e6c7017..0cfd00bcda 100644
+--- a/scene/resources/sky.h
++++ b/scene/resources/sky.h
+@@ -190,7 +190,7 @@ public:
+ 	void set_texture_size(TextureSize p_size);
+ 	TextureSize get_texture_size() const;
+ 
+-	Ref<Image> get_panorama() const;
++	Ref<Image> get_data() const;
+ 
+ 	virtual RID get_rid() const;
+ 
+-- 
+2.31.1
+
diff --git a/trunk/0002-embree-Allow-building-against-system-library-on-Linu.patch b/trunk/0002-embree-Allow-building-against-system-library-on-Linu.patch
new file mode 100644
index 0000000..699f8d9
--- /dev/null
+++ b/trunk/0002-embree-Allow-building-against-system-library-on-Linu.patch
@@ -0,0 +1,224 @@
+From 66625962bff3b83caae324d6e9d402e2bfacc48f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= <rverschelde@gmail.com>
+Date: Thu, 22 Apr 2021 02:03:43 +0200
+Subject: [PATCH] embree: Allow building against system library on Linux
+
+(cherry picked from commit b266cc2315f2d8fb1615e2c4f18558e602a7a700)
+---
+ SConstruct             |   1 +
+ modules/raycast/SCsub  | 165 +++++++++++++++++++++--------------------
+ platform/x11/detect.py |   4 +
+ 3 files changed, 90 insertions(+), 80 deletions(-)
+
+diff --git a/SConstruct b/SConstruct
+index c30f53308b..7abe58ba49 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -151,6 +151,7 @@ opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise e
+ # Thirdparty libraries
+ opts.Add(BoolVariable("builtin_bullet", "Use the built-in Bullet library", True))
+ opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundles", True))
++opts.Add(BoolVariable("builtin_embree", "Use the built-in Embree library", True))
+ opts.Add(BoolVariable("builtin_enet", "Use the built-in ENet library", True))
+ opts.Add(BoolVariable("builtin_freetype", "Use the built-in FreeType library", True))
+ opts.Add(BoolVariable("builtin_libogg", "Use the built-in libogg library", True))
+diff --git a/modules/raycast/SCsub b/modules/raycast/SCsub
+index 789d7d3251..e6808d76ba 100644
+--- a/modules/raycast/SCsub
++++ b/modules/raycast/SCsub
+@@ -3,92 +3,97 @@
+ Import("env")
+ Import("env_modules")
+ 
+-embree_src = [
+-    "common/sys/sysinfo.cpp",
+-    "common/sys/alloc.cpp",
+-    "common/sys/filename.cpp",
+-    "common/sys/library.cpp",
+-    "common/sys/thread.cpp",
+-    "common/sys/string.cpp",
+-    "common/sys/regression.cpp",
+-    "common/sys/mutex.cpp",
+-    "common/sys/condition.cpp",
+-    "common/sys/barrier.cpp",
+-    "common/math/constants.cpp",
+-    "common/simd/sse.cpp",
+-    "common/lexers/stringstream.cpp",
+-    "common/lexers/tokenstream.cpp",
+-    "common/tasking/taskschedulerinternal.cpp",
+-    "common/algorithms/parallel_for.cpp",
+-    "common/algorithms/parallel_reduce.cpp",
+-    "common/algorithms/parallel_prefix_sum.cpp",
+-    "common/algorithms/parallel_for_for.cpp",
+-    "common/algorithms/parallel_for_for_prefix_sum.cpp",
+-    "common/algorithms/parallel_partition.cpp",
+-    "common/algorithms/parallel_sort.cpp",
+-    "common/algorithms/parallel_set.cpp",
+-    "common/algorithms/parallel_map.cpp",
+-    "common/algorithms/parallel_filter.cpp",
+-    "kernels/common/device.cpp",
+-    "kernels/common/stat.cpp",
+-    "kernels/common/acceln.cpp",
+-    "kernels/common/accelset.cpp",
+-    "kernels/common/state.cpp",
+-    "kernels/common/rtcore.cpp",
+-    "kernels/common/rtcore_builder.cpp",
+-    "kernels/common/scene.cpp",
+-    "kernels/common/alloc.cpp",
+-    "kernels/common/geometry.cpp",
+-    "kernels/common/scene_triangle_mesh.cpp",
+-    "kernels/geometry/primitive4.cpp",
+-    "kernels/builders/primrefgen.cpp",
+-    "kernels/bvh/bvh.cpp",
+-    "kernels/bvh/bvh_statistics.cpp",
+-    "kernels/bvh/bvh4_factory.cpp",
+-    "kernels/bvh/bvh8_factory.cpp",
+-    "kernels/bvh/bvh_collider.cpp",
+-    "kernels/bvh/bvh_rotate.cpp",
+-    "kernels/bvh/bvh_refit.cpp",
+-    "kernels/bvh/bvh_builder.cpp",
+-    "kernels/bvh/bvh_builder_morton.cpp",
+-    "kernels/bvh/bvh_builder_sah.cpp",
+-    "kernels/bvh/bvh_builder_sah_spatial.cpp",
+-    "kernels/bvh/bvh_builder_sah_mb.cpp",
+-    "kernels/bvh/bvh_builder_twolevel.cpp",
+-    "kernels/bvh/bvh_intersector1_bvh4.cpp",
+-]
++env_raycast = env_modules.Clone()
++
++# Thirdparty source files
+ 
+-embree_dir = "#thirdparty/embree/"
++if env["builtin_embree"]:
++    thirdparty_dir = "#thirdparty/embree/"
+ 
+-env_embree = env_modules.Clone()
+-embree_sources = [embree_dir + file for file in embree_src]
+-env_embree.Prepend(CPPPATH=[embree_dir, embree_dir + "include"])
+-env_embree.Append(
+-    CPPFLAGS=[
+-        "-DEMBREE_TARGET_SSE2",
+-        "-DEMBREE_LOWEST_ISA",
+-        "-DTASKING_INTERNAL",
+-        "-DNDEBUG",
+-        "-D__SSE2__",
+-        "-D__SSE__",
++    embree_src = [
++        "common/sys/sysinfo.cpp",
++        "common/sys/alloc.cpp",
++        "common/sys/filename.cpp",
++        "common/sys/library.cpp",
++        "common/sys/thread.cpp",
++        "common/sys/string.cpp",
++        "common/sys/regression.cpp",
++        "common/sys/mutex.cpp",
++        "common/sys/condition.cpp",
++        "common/sys/barrier.cpp",
++        "common/math/constants.cpp",
++        "common/simd/sse.cpp",
++        "common/lexers/stringstream.cpp",
++        "common/lexers/tokenstream.cpp",
++        "common/tasking/taskschedulerinternal.cpp",
++        "common/algorithms/parallel_for.cpp",
++        "common/algorithms/parallel_reduce.cpp",
++        "common/algorithms/parallel_prefix_sum.cpp",
++        "common/algorithms/parallel_for_for.cpp",
++        "common/algorithms/parallel_for_for_prefix_sum.cpp",
++        "common/algorithms/parallel_partition.cpp",
++        "common/algorithms/parallel_sort.cpp",
++        "common/algorithms/parallel_set.cpp",
++        "common/algorithms/parallel_map.cpp",
++        "common/algorithms/parallel_filter.cpp",
++        "kernels/common/device.cpp",
++        "kernels/common/stat.cpp",
++        "kernels/common/acceln.cpp",
++        "kernels/common/accelset.cpp",
++        "kernels/common/state.cpp",
++        "kernels/common/rtcore.cpp",
++        "kernels/common/rtcore_builder.cpp",
++        "kernels/common/scene.cpp",
++        "kernels/common/alloc.cpp",
++        "kernels/common/geometry.cpp",
++        "kernels/common/scene_triangle_mesh.cpp",
++        "kernels/geometry/primitive4.cpp",
++        "kernels/builders/primrefgen.cpp",
++        "kernels/bvh/bvh.cpp",
++        "kernels/bvh/bvh_statistics.cpp",
++        "kernels/bvh/bvh4_factory.cpp",
++        "kernels/bvh/bvh8_factory.cpp",
++        "kernels/bvh/bvh_collider.cpp",
++        "kernels/bvh/bvh_rotate.cpp",
++        "kernels/bvh/bvh_refit.cpp",
++        "kernels/bvh/bvh_builder.cpp",
++        "kernels/bvh/bvh_builder_morton.cpp",
++        "kernels/bvh/bvh_builder_sah.cpp",
++        "kernels/bvh/bvh_builder_sah_spatial.cpp",
++        "kernels/bvh/bvh_builder_sah_mb.cpp",
++        "kernels/bvh/bvh_builder_twolevel.cpp",
++        "kernels/bvh/bvh_intersector1_bvh4.cpp",
+     ]
+-)
+ 
+-if not env_embree.msvc:
+-    env_embree.Append(CPPFLAGS=["-msse2", "-mxsave"])
+-    if env["platform"] == "windows":
+-        env_embree.Append(CPPFLAGS=["-mstackrealign"])
++    thirdparty_sources = [thirdparty_dir + file for file in embree_src]
+ 
+-if env["platform"] == "windows":
+-    if env.msvc:
+-        env.Append(LINKFLAGS=["psapi.lib"])
+-    else:
+-        env.Append(LIBS=["psapi"])
++    env_raycast.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "include"])
++    env_raycast.Append(
++        CPPDEFINES=[
++            "EMBREE_TARGET_SSE2",
++            "EMBREE_LOWEST_ISA",
++            "TASKING_INTERNAL",
++            "NDEBUG",
++            "__SSE2__",
++            "__SSE__",
++        ]
++    )
+ 
+-env_embree.disable_warnings()
+-env_embree.add_source_files(env.modules_sources, embree_sources)
++    if not env.msvc:
++        env_raycast.Append(CPPFLAGS=["-msse2", "-mxsave"])
++        if env["platform"] == "windows":
++            env_raycast.Append(CPPFLAGS=["-mstackrealign"])
++
++    if env["platform"] == "windows":
++        if env.msvc:
++            env.Append(LINKFLAGS=["psapi.lib"])
++        else:
++            env.Append(LIBS=["psapi"])
++
++    env_thirdparty = env_raycast.Clone()
++    env_thirdparty.disable_warnings()
++    env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)
+ 
+-env_raycast = env_modules.Clone()
+-env_raycast.Prepend(CPPPATH=[embree_dir, embree_dir + "include", embree_dir + "common"])
+ 
++# Godot source files
+ env_raycast.add_source_files(env.modules_sources, "*.cpp")
+diff --git a/platform/x11/detect.py b/platform/x11/detect.py
+index ba5fb30d2e..7513bd701f 100644
+--- a/platform/x11/detect.py
++++ b/platform/x11/detect.py
+@@ -310,6 +310,10 @@ def configure(env):
+     if not env["builtin_pcre2"]:
+         env.ParseConfig("pkg-config libpcre2-32 --cflags --libs")
+ 
++    if not env["builtin_embree"]:
++        # No pkgconfig file so far, hardcode expected lib name.
++        env.Append(LIBS=["embree3"])
++
+     ## Flags
+ 
+     if os.system("pkg-config --exists alsa") == 0:  # 0 means found
+-- 
+2.31.1
+
diff --git a/trunk/0003-lightmapper-Disable-build-if-raycast-module-can-t-bu.patch b/trunk/0003-lightmapper-Disable-build-if-raycast-module-can-t-bu.patch
new file mode 100644
index 0000000..cc7ab76
--- /dev/null
+++ b/trunk/0003-lightmapper-Disable-build-if-raycast-module-can-t-bu.patch
@@ -0,0 +1,76 @@
+From 4e1360ac5922d3da9e2d2bcf67be22bb723efa92 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= <rverschelde@gmail.com>
+Date: Thu, 22 Apr 2021 18:53:43 +0200
+Subject: [PATCH] lightmapper: Disable build if raycast module can't build
+
+We need to propagate the hacky checks from the raycast config to the
+lightmapper config, as the failure of a `can_build()` check is not notified to
+other modules (which might even be checked further depending on the processing
+order in SConstruct).
+
+A more thorough fix would be to change SConstruct to do two loops on modules:
+one to check `can_build()` and disable modules which can't build, then another
+one to rechecked `can_build()` with the new lineup and do further config.
+But there would be more risk for regressions than with this ad hoc hack.
+
+Similar story for the `platform/x11/detect.py` change... oh my eyes :(
+
+(cherry picked from commit a2c68d9da71053efa3ca7de6162aa71bc3651b92)
+---
+ modules/lightmapper_cpu/config.py | 25 ++++++++++++++++++++++++-
+ platform/x11/detect.py            |  5 ++++-
+ 2 files changed, 28 insertions(+), 2 deletions(-)
+
+diff --git a/modules/lightmapper_cpu/config.py b/modules/lightmapper_cpu/config.py
+index d01c1726dd..0b8837aa4e 100644
+--- a/modules/lightmapper_cpu/config.py
++++ b/modules/lightmapper_cpu/config.py
+@@ -1,5 +1,28 @@
+ def can_build(env, platform):
+-    return env["tools"] and env["module_raycast_enabled"]
++    if not env["tools"] or not env["module_raycast_enabled"]:
++        return False
++
++    # Depends on raycast module (embree), but we can't have access to the result of
++    # `can_build()` for that module, so we need to duplicate that code as a short-term
++    # solution.
++
++    # Embree requires at least SSE2 to be available, so 32-bit and ARM64 builds are
++    # not supported.
++    # It's also only relevant for tools build and desktop platforms,
++    # as doing lightmap generation on Android or HTML5 would be a bit far-fetched.
++    supported_platform = platform in ["x11", "osx", "windows", "server"]
++    supported_bits = env["bits"] == "64"
++    supported_arch = env["arch"] != "arm64"
++
++    # Hack to disable on Linux arm64. This won't work well for cross-compilation (checks
++    # host, not target) and would need a more thorough fix by refactoring our arch and
++    # bits-handling code.
++    from platform import machine
++
++    if platform == "x11" and machine() != "x86_64":
++        supported_arch = False
++
++    return supported_platform and supported_bits and supported_arch
+ 
+ 
+ def configure(env):
+diff --git a/platform/x11/detect.py b/platform/x11/detect.py
+index 7513bd701f..ada0669a69 100644
+--- a/platform/x11/detect.py
++++ b/platform/x11/detect.py
+@@ -310,7 +310,10 @@ def configure(env):
+     if not env["builtin_pcre2"]:
+         env.ParseConfig("pkg-config libpcre2-32 --cflags --libs")
+ 
+-    if not env["builtin_embree"]:
++    # Embree is only compatible with x86_64. Yet another unreliable hack that will break
++    # cross-compilation, this will really need to be handle better. Thankfully only affects
++    # people who disable builtin_embree (likely distro packagers).
++    if not env["builtin_embree"] and (is64 and platform.machine() == "x86_64"):
+         # No pkgconfig file so far, hardcode expected lib name.
+         env.Append(LIBS=["embree3"])
+ 
+-- 
+2.31.1
+
diff --git a/trunk/0004-Linux-Don-t-attempt-linking-embree3-on-non-tools-lin.patch b/trunk/0004-Linux-Don-t-attempt-linking-embree3-on-non-tools-lin.patch
new file mode 100644
index 0000000..d85191c
--- /dev/null
+++ b/trunk/0004-Linux-Don-t-attempt-linking-embree3-on-non-tools-lin.patch
@@ -0,0 +1,51 @@
+From 162c78f9dca3669f84c837356730a5d33a63060b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= <rverschelde@gmail.com>
+Date: Fri, 23 Apr 2021 10:25:51 +0200
+Subject: [PATCH] Linux: Don't attempt linking embree3 on non-tools, link it
+ for headless too
+
+`tech_debt++`, that's what we get for not taking the time to cleanup all this
+and do it right...
+
+Follow-up to #48073 and #48102.
+
+(cherry picked from commit a14b51df924cbdd915f46571b396d6b9ac6e84ff)
+---
+ platform/server/detect.py | 7 +++++++
+ platform/x11/detect.py    | 2 +-
+ 2 files changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/platform/server/detect.py b/platform/server/detect.py
+index 59eb3dc5cb..49fbdedd3f 100644
+--- a/platform/server/detect.py
++++ b/platform/server/detect.py
+@@ -222,6 +222,13 @@ def configure(env):
+     if not env["builtin_pcre2"]:
+         env.ParseConfig("pkg-config libpcre2-32 --cflags --libs")
+ 
++    # Embree is only compatible with x86_64. Yet another unreliable hack that will break
++    # cross-compilation, this will really need to be handle better. Thankfully only affects
++    # people who disable builtin_embree (likely distro packagers).
++    if env["tools"] and not env["builtin_embree"] and (is64 and platform.machine() == "x86_64"):
++        # No pkgconfig file so far, hardcode expected lib name.
++        env.Append(LIBS=["embree3"])
++
+     ## Flags
+ 
+     # Linkflags below this line should typically stay the last ones
+diff --git a/platform/x11/detect.py b/platform/x11/detect.py
+index ada0669a69..1a52044150 100644
+--- a/platform/x11/detect.py
++++ b/platform/x11/detect.py
+@@ -313,7 +313,7 @@ def configure(env):
+     # Embree is only compatible with x86_64. Yet another unreliable hack that will break
+     # cross-compilation, this will really need to be handle better. Thankfully only affects
+     # people who disable builtin_embree (likely distro packagers).
+-    if not env["builtin_embree"] and (is64 and platform.machine() == "x86_64"):
++    if env["tools"] and not env["builtin_embree"] and (is64 and platform.machine() == "x86_64"):
+         # No pkgconfig file so far, hardcode expected lib name.
+         env.Append(LIBS=["embree3"])
+ 
+-- 
+2.31.1
+
diff --git a/trunk/06c42d151cf7b70b73dda42eba78e91b05c12814.patch b/trunk/06c42d151cf7b70b73dda42eba78e91b05c12814.patch
new file mode 100644
index 0000000..2e22a6d
--- /dev/null
+++ b/trunk/06c42d151cf7b70b73dda42eba78e91b05c12814.patch
@@ -0,0 +1,33 @@
+From 34e2d2f4f7224ac24dec5f0461d80cb9dfddb827 Mon Sep 17 00:00:00 2001
+From: Marcelo Fernandez <marcelofg55@gmail.com>
+Date: Mon, 5 Nov 2018 21:34:36 -0300
+Subject: [PATCH] Fix binaries incorrectly detected as shared libraries on some
+ linux distros
+
+---
+ platform/x11/detect.py | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/platform/x11/detect.py b/platform/x11/detect.py
+index ee59e9b5a17..dc5c22b4b3b 100644
+--- a/platform/x11/detect.py
++++ b/platform/x11/detect.py
+@@ -149,6 +149,18 @@ def configure(env):
+     env.Append(CCFLAGS=['-pipe'])
+     env.Append(LINKFLAGS=['-pipe'])
+ 
++    # Check for gcc version >= 6 before adding -no-pie
++    version = get_compiler_version(env) or [-1, -1]
++    if using_gcc(env):
++        if version[0] >= 6:
++            env.Append(CCFLAGS=["-fpie"])
++            env.Append(LINKFLAGS=["-no-pie"])
++    # Do the same for clang should be fine with Clang 4 and higher
++    if using_clang(env):
++        if version[0] >= 4:
++            env.Append(CCFLAGS=["-fpie"])
++            env.Append(LINKFLAGS=["-no-pie"])
++
+     ## Dependencies
+ 
+     env.ParseConfig('pkg-config x11 --cflags --libs')
diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD
index 45a4130..e2b9c4a 100644
--- a/trunk/PKGBUILD
+++ b/trunk/PKGBUILD
@@ -11,14 +11,52 @@ url='https://godotengine.org'
 license=(MIT)
 arch=(x86_64)
 makedepends=(gcc scons yasm)
-depends=(alsa-lib freetype2 libglvnd libxcursor libxinerama libxrandr pulseaudio)
-source=("$pkgname-$pkgver.tar.gz::https://github.com/godotengine/godot/archive/$pkgver-stable.tar.gz")
-b2sums=('280b3b371c96e7a39e23f843759754e932fe4fd62b774b5d2d0d0e687fdb5dc8be7d95a18465f52d6f00456f62451115b1bf2e4afc2923ce704ffcde0f06544d')
+depends=(alsa-lib freetype2 libglvnd libxcursor libxinerama libxrandr pulseaudio embree
+         bullet libogg libpng libtheora libvorbis libvpx libwebp mbedtls miniupnpc opus opusfile pcre2 zlib zstd)
+source=("$pkgname-$pkgver.tar.gz::https://github.com/godotengine/godot/archive/$pkgver-stable.tar.gz"
+         06c42d151cf7b70b73dda42eba78e91b05c12814.patch
+         godot-fbx-Fix-include-for-zlib-that-broke-unbundling.patch
+         0001-CPU-lightmapper-environment-energy-fixes.patch
+         0002-embree-Allow-building-against-system-library-on-Linu.patch
+         0003-lightmapper-Disable-build-if-raycast-module-can-t-bu.patch
+         0004-Linux-Don-t-attempt-linking-embree3-on-non-tools-lin.patch)
+b2sums=('280b3b371c96e7a39e23f843759754e932fe4fd62b774b5d2d0d0e687fdb5dc8be7d95a18465f52d6f00456f62451115b1bf2e4afc2923ce704ffcde0f06544d'
+        'b9c02d4620c6d70e5fa828d1cc8aa4a42311c988becec40f4f2c65ce59a637ebf3db45cb91734b8c8c45ff73ec02dff76bcec5326ae42106fc43210a9bd29040'
+        '05cf2cfcae5418d38f7ec70da72f3b60f0d89606678eba2dc683ede088d2b7097a7aa0a645b47bb0b01e9caa40ec9b9a3cf5bfd3475b68aba87d066befc82d7e'
+        'b3bffa8c1862e28248298b0e37308bbeb65e1cac9a0a180b26f310b0e35fc713fe261f47e7744e5e6ac4e76b7ee79dc779628adeed6c41600626b2c88bdb8ee7'
+        '52ff2d8d478bd74b7bc00e74adc381c2951b70e528373c7eb8bf8253fad05a0cbab8efd7e40dc65c65ccfd4b3c3a725192447c47849748b076fc75e13e192edb'
+        'e220f658efb6387553479d5f5ecf444645aa51443ff66c6f1aa41660855a75c457db6ffa8e3cfffe2759cfaa3e7576ca178b68d44cd73cf2170e345856937b77'
+        '837a36b6a5463f66273cfa037dca4744dcc9ed561799537d86d69184034b05b6f4a6a75ca0aad1911c857e617f1b7b3759579a71d512325e1b2ca10f09551917')
+
+prepare() {
+  cd $pkgname-$pkgver-stable
+  patch -p1 -R -i../06c42d151cf7b70b73dda42eba78e91b05c12814.patch
+  patch -p1 -i ../godot-fbx-Fix-include-for-zlib-that-broke-unbundling.patch
+  patch -p1 -i ../0001-CPU-lightmapper-environment-energy-fixes.patch
+  patch -p1 -i ../0002-embree-Allow-building-against-system-library-on-Linu.patch
+  patch -p1 -i ../0003-lightmapper-Disable-build-if-raycast-module-can-t-bu.patch
+  patch -p1 -i ../0004-Linux-Don-t-attempt-linking-embree3-on-non-tools-lin.patch
+}
 
 build() {
+#Not unbundled:
+#  enet contains none upstreamed IPv6 support
+#  libwebm AUR
+#  recast
+#  squish AUR libsquish
+#  wslay AUR
+#  xatlas
+to_unbundle="bullet certs embree freetype libogg libpng libtheora libvorbis libvpx libwebp mbedtls miniupnpc opus pcre2 zlib zstd"
+system_libs=""
+for lib in $to_unbundle; do
+    system_libs+="builtin_"$lib"=no "
+    rm -rf thirdparty/$lib
+done
+
   cd $pkgname-$pkgver-stable
   export BUILD_NAME=arch_linux
-  scons -j12 \
+  scons -j16 \
+    system_certs_path=/etc/ssl/certs/ca-certificates.crt \
     bits=64 \
     colored=yes \
     platform=x11 \
@@ -26,9 +64,10 @@ build() {
     target=release_debug \
     tools=yes \
     use_llvm=no \
-    CFLAGS="$CFLAGS -Wl,-z,relro,-z-now -w" \
-    CXXFLAGS="$CXXFLAGS -Wl,-z,relro,-z-now -w" \
-    LINKFLAGS="$LDFLAGS -Wl,-z,relro,-z-now -w"
+    CFLAGS="$CFLAGS" \
+    CXXFLAGS="$CXXFLAGS" \
+    LINKFLAGS="$LDFLAGS" \
+    $system_libs
 }
 
 package() {
diff --git a/trunk/godot-fbx-Fix-include-for-zlib-that-broke-unbundling.patch b/trunk/godot-fbx-Fix-include-for-zlib-that-broke-unbundling.patch
new file mode 100644
index 0000000..3743587
--- /dev/null
+++ b/trunk/godot-fbx-Fix-include-for-zlib-that-broke-unbundling.patch
@@ -0,0 +1,44 @@
+From b616f41573ce56e872f73f160345da8a86504375 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= <rverschelde@gmail.com>
+Date: Thu, 22 Apr 2021 02:18:44 +0200
+Subject: [PATCH] fbx: Fix include for zlib that broke unbundling
+
+It's possible to link against system zlib on Linux, so we should use system paths.
+
+(cherry picked from commit 93b74061387075909d1b4d29b0e5b2924e06f7d7)
+---
+ modules/fbx/SCsub                    | 3 +++
+ modules/fbx/fbx_parser/FBXParser.cpp | 2 +-
+ 2 files changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/modules/fbx/SCsub b/modules/fbx/SCsub
+index 84220a66fa..0311fddfee 100644
+--- a/modules/fbx/SCsub
++++ b/modules/fbx/SCsub
+@@ -8,6 +8,9 @@ env_fbx = env_modules.Clone()
+ # Make includes relative to the folder path specified here so our includes are clean
+ env_fbx.Prepend(CPPPATH=["#modules/fbx/"])
+ 
++if env["builtin_zlib"]:
++    env_fbx.Prepend(CPPPATH=["#thirdparty/zlib/"])
++
+ # Godot's own source files
+ env_fbx.add_source_files(env.modules_sources, "tools/*.cpp")
+ env_fbx.add_source_files(env.modules_sources, "data/*.cpp")
+diff --git a/modules/fbx/fbx_parser/FBXParser.cpp b/modules/fbx/fbx_parser/FBXParser.cpp
+index 0d737eb272..e9e44d94bf 100644
+--- a/modules/fbx/fbx_parser/FBXParser.cpp
++++ b/modules/fbx/fbx_parser/FBXParser.cpp
+@@ -74,8 +74,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *  @brief Implementation of the FBX parser and the rudimentary DOM that we use
+  */
+ 
+-#include "thirdparty/zlib/zlib.h"
+ #include <stdlib.h> /* strtol */
++#include <zlib.h>
+ 
+ #include "ByteSwapper.h"
+ #include "FBXParseTools.h"
+-- 
+2.31.1
+

[1] https://github.com/godotengine/godot/co … 1b05c12814
[2] https://github.com/godotengine/godot/pull/23542
[3] https://github.com/hpvb/dynamic-linktime-load

Offline

Board footer

Powered by FluxBB