forked from pool/glslang
This commit is contained in:
parent
b953e204f0
commit
67f287d619
108
badcode.diff
Normal file
108
badcode.diff
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
|
||||||
|
wtf, code with undefined behavior.
|
||||||
|
|
||||||
|
SPIRV/SpvBuilder.cpp:701:39: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
|
||||||
|
unsigned value = *(unsigned int*)&f;
|
||||||
|
SPIRV/SpvBuilder.cpp:724:55: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
|
||||||
|
unsigned long long value = *(unsigned long long*)&d;
|
||||||
|
glslang/MachineIndependent/Constant.cpp:51:31: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
|
||||||
|
int bitPatternL = *(int*)&x;
|
||||||
|
glslang/MachineIndependent/Constant.cpp:60:31: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
|
||||||
|
int bitPatternL = *(int*)&x;
|
||||||
|
|
||||||
|
And pointless compile timestamps.
|
||||||
|
glslang-devel.x86_64: W: file-contains-date-and-time /usr/bin/spirv-remap
|
||||||
|
Your file uses __DATE and __TIME__ this causes the package to rebuild when
|
||||||
|
---
|
||||||
|
SPIRV/SpvBuilder.cpp | 9 +++++++--
|
||||||
|
StandAlone/spirv-remap.cpp | 2 +-
|
||||||
|
glslang/MachineIndependent/Constant.cpp | 15 +++++++++++----
|
||||||
|
3 files changed, 19 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
Index: glslang-2.3.g244/SPIRV/SpvBuilder.cpp
|
||||||
|
===================================================================
|
||||||
|
--- glslang-2.3.g244.orig/SPIRV/SpvBuilder.cpp
|
||||||
|
+++ glslang-2.3.g244/SPIRV/SpvBuilder.cpp
|
||||||
|
@@ -53,6 +53,7 @@
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <cstdio>
|
||||||
|
#endif
|
||||||
|
+#include <cstring>
|
||||||
|
|
||||||
|
namespace spv {
|
||||||
|
|
||||||
|
@@ -698,7 +699,9 @@ Id Builder::makeFloatConstant(float f, b
|
||||||
|
{
|
||||||
|
Op opcode = specConstant ? OpSpecConstant : OpConstant;
|
||||||
|
Id typeId = makeFloatType(32);
|
||||||
|
- unsigned value = *(unsigned int*)&f;
|
||||||
|
+ unsigned value;
|
||||||
|
+ static_assert(sizeof(value) <= sizeof(float), "horrible code");
|
||||||
|
+ memcpy(&value, &f, sizeof(value));
|
||||||
|
|
||||||
|
// See if we already made it. Applies only to regular constants, because specialization constants
|
||||||
|
// must remain distinct for the purpose of applying a SpecId decoration.
|
||||||
|
@@ -721,7 +724,9 @@ Id Builder::makeDoubleConstant(double d,
|
||||||
|
{
|
||||||
|
Op opcode = specConstant ? OpSpecConstant : OpConstant;
|
||||||
|
Id typeId = makeFloatType(64);
|
||||||
|
- unsigned long long value = *(unsigned long long*)&d;
|
||||||
|
+ unsigned long long value;
|
||||||
|
+ static_assert(sizeof(value) <= sizeof(d), "horrible code");
|
||||||
|
+ memcpy(&value, &d, sizeof(value));
|
||||||
|
unsigned op1 = value & 0xFFFFFFFF;
|
||||||
|
unsigned op2 = value >> 32;
|
||||||
|
|
||||||
|
Index: glslang-2.3.g244/StandAlone/spirv-remap.cpp
|
||||||
|
===================================================================
|
||||||
|
--- glslang-2.3.g244.orig/StandAlone/spirv-remap.cpp
|
||||||
|
+++ glslang-2.3.g244/StandAlone/spirv-remap.cpp
|
||||||
|
@@ -225,7 +225,7 @@ namespace {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (arg == "--version" || arg == "-V") {
|
||||||
|
- std::cout << basename(argv[0]) << " version 0.97 " << __DATE__ << " " << __TIME__ << std::endl;
|
||||||
|
+ std::cout << basename(argv[0]) << " version 0.97 " << "__DATE__" << " " << "__TIME__" << std::endl;
|
||||||
|
exit(0);
|
||||||
|
} else if (arg == "--input" || arg == "-i") {
|
||||||
|
// Collect input files
|
||||||
|
Index: glslang-2.3.g244/glslang/MachineIndependent/Constant.cpp
|
||||||
|
===================================================================
|
||||||
|
--- glslang-2.3.g244.orig/glslang/MachineIndependent/Constant.cpp
|
||||||
|
+++ glslang-2.3.g244/glslang/MachineIndependent/Constant.cpp
|
||||||
|
@@ -38,6 +38,7 @@
|
||||||
|
#include <cmath>
|
||||||
|
#include <cfloat>
|
||||||
|
#include <cstdlib>
|
||||||
|
+#include <cstring>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
@@ -48,8 +49,11 @@ using namespace glslang;
|
||||||
|
bool isNan(double x)
|
||||||
|
{
|
||||||
|
// tough to find a platform independent library function, do it directly
|
||||||
|
- int bitPatternL = *(int*)&x;
|
||||||
|
- int bitPatternH = *((int*)&x + 1);
|
||||||
|
+ int bitPatternL;
|
||||||
|
+ static_assert(sizeof(int[2]) <= sizeof(x), "horrible code");
|
||||||
|
+ memcpy(&bitPatternL, &x, sizeof(bitPatternL));
|
||||||
|
+ int bitPatternH;
|
||||||
|
+ memcpy(&bitPatternH, reinterpret_cast<int *>(&x) + 1, sizeof(bitPatternH));
|
||||||
|
return (bitPatternH & 0x7ff80000) == 0x7ff80000 &&
|
||||||
|
((bitPatternH & 0xFFFFF) != 0 || bitPatternL != 0);
|
||||||
|
}
|
||||||
|
@@ -57,8 +61,11 @@ bool isNan(double x)
|
||||||
|
bool isInf(double x)
|
||||||
|
{
|
||||||
|
// tough to find a platform independent library function, do it directly
|
||||||
|
- int bitPatternL = *(int*)&x;
|
||||||
|
- int bitPatternH = *((int*)&x + 1);
|
||||||
|
+ int bitPatternL;
|
||||||
|
+ static_assert(sizeof(int[2]) <= sizeof(x), "horrible code");
|
||||||
|
+ memcpy(&bitPatternL, &x, sizeof(bitPatternL));
|
||||||
|
+ int bitPatternH;
|
||||||
|
+ memcpy(&bitPatternH, reinterpret_cast<int *>(&x) + 1, sizeof(bitPatternH));
|
||||||
|
return (bitPatternH & 0x7ff00000) == 0x7ff00000 &&
|
||||||
|
(bitPatternH & 0xFFFFF) == 0 && bitPatternL == 0;
|
||||||
|
}
|
@ -25,6 +25,7 @@ Group: Development/Libraries/C and C++
|
|||||||
Url: https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
|
Url: https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
|
||||||
|
|
||||||
Source: %name-%version.tar.xz
|
Source: %name-%version.tar.xz
|
||||||
|
Patch1: badcode.diff
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
BuildRequires: bison
|
BuildRequires: bison
|
||||||
BuildRequires: cmake >= 2.8
|
BuildRequires: cmake >= 2.8
|
||||||
@ -54,6 +55,7 @@ compressor's dictionary can find better cross module commonality.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
|
%patch -P 1 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%cmake
|
%cmake
|
||||||
@ -62,13 +64,16 @@ make %{?_smp_mflags}
|
|||||||
%install
|
%install
|
||||||
b="%buildroot"
|
b="%buildroot"
|
||||||
%cmake_install
|
%cmake_install
|
||||||
|
# So much fail in this source package..
|
||||||
if test "%_lib" != lib; then
|
if test "%_lib" != lib; then
|
||||||
mkdir -p "$b/%_libdir"
|
mkdir -p "$b/%_libdir"
|
||||||
mv "$b/%_prefix/lib"/*.a "$b/%_libdir/"
|
mv "$b/%_prefix/lib"/*.a "$b/%_libdir/"
|
||||||
fi
|
fi
|
||||||
mkdir -p "$b/%_includedir"
|
mkdir -p "$b/%_includedir"
|
||||||
cp -a SPIRV glslang "$b/%_includedir/"
|
cp -a SPIRV glslang "$b/%_includedir/"
|
||||||
find "$b/%_includedir/" -type f ! -iname "*.h" -delete
|
find "$b/%_includedir/" -type f ! -iname "*.h" -a ! -iname "*.hpp" -print -delete
|
||||||
|
ln -s SPIRV/spirv.hpp "$b/%_includedir/"
|
||||||
|
find "$b/%_includedir/" -type f -exec chmod a-x "{}" "+"
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
|
Loading…
Reference in New Issue
Block a user