Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from upstream shaderc #1

Merged
merged 12 commits into from
Dec 29, 2023
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ third_party/tint
android_test/libs
android_test/include
.DS_Store
.vscode/
2 changes: 0 additions & 2 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ include $(ROOT_SHADERC_PATH)/libshaderc_util/Android.mk
include $(ROOT_SHADERC_PATH)/libshaderc/Android.mk

ALL_LIBS:=libglslang.a \
libOGLCompiler.a \
libOSDependent.a \
libshaderc.a \
libshaderc_util.a \
libSPIRV.a \
libHLSL.a \
libSPIRV-Tools.a \
libSPIRV-Tools-opt.a

Expand Down
9 changes: 7 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
Revision history for Shaderc

v2023.7-dev 2023-08-09
- Start v2023.7 development
v2023.8-dev 2023-10-12
- Start development

v2023.7 2023-10-12
- Update dependencies
- Finish converting build instructions and flags to always use C++17
- Add GitHub CI to test more flows

v2023.6 2023-08-09
- Update dependencies, including SPIRV-Tools v2023.4.rc2
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ if (COMPILER_SUPPORTS_EXTRA_SEMI_WARNING)
add_compile_options("-Wextra-semi")
endif()

find_host_package(PythonInterp 3 REQUIRED)
if(${CMAKE_VERSION} VERSION_LESS_EQUAL "3.12")
find_package(PythonInterp 3 REQUIRED)
else ()
find_package(Python COMPONENTS Interpreter REQUIRED)
endif ()

if (SHADERC_ENABLE_COPYRIGHT_CHECK)
add_custom_target(check-copyright ALL
Expand Down
8 changes: 4 additions & 4 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ vars = {

'abseil_revision': '5be22f98733c674d532598454ae729253bc53e82',
'effcee_revision' : '19b4aa87af25cb4ee779a071409732f34bfc305c',
'glslang_revision': '76b52ebf77833908dc4c0dd6c70a9c357ac720bd',
'googletest_revision': 'c541e7c11044b1e0303103ef8a47d7a9632c479b',
'glslang_revision': '6be56e45e574b375d759b89dad35f780bbd4792f',
'googletest_revision': 'e47544ad31cb3ceecd04cc13e8fe556f8df9fe0b',
're2_revision': 'c9cba76063cf4235c1a15dd14a24a4ef8d623761',
'spirv_headers_revision': '124a9665e464ef98b8b718d572d5f329311061eb',
'spirv_tools_revision': '8e3da01b45806fbacbb9e6fce9c5f9ae49f60e42',
'spirv_headers_revision': '4183b260f4cccae52a89efdfcdd43c4897989f42',
'spirv_tools_revision': '360d469b9eac54d6c6e20f609f9ec35e3a5380ad',
}

deps = {
Expand Down
6 changes: 5 additions & 1 deletion cmake/setup_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ if (ANDROID)
find_host_package(PythonInterp 3 REQUIRED)
find_host_package(BISON)
else()
find_package(PythonInterp 3 REQUIRED)
if(${CMAKE_VERSION} VERSION_LESS_EQUAL "3.12")
find_package(PythonInterp 3 REQUIRED)
else ()
find_package(Python COMPONENTS Interpreter REQUIRED)
endif ()
endif()

option(DISABLE_RTTI "Disable RTTI in builds")
Expand Down
49 changes: 4 additions & 45 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ endfunction(shaderc_default_c_compile_options)
function(shaderc_default_compile_options TARGET)
shaderc_default_c_compile_options(${TARGET})
if (NOT "${MSVC}")
target_compile_options(${TARGET} PRIVATE -std=c++11)
if (NOT SHADERC_ENABLE_SHARED_CRT)
if (WIN32)
# For MinGW cross compile, statically link to the C++ runtime.
Expand Down Expand Up @@ -174,50 +173,10 @@ endmacro()
# Combines the static library "target" with all of its transitive static
# library dependencies into a single static library "new_target".
function(shaderc_combine_static_lib new_target target)

set(all_libs "")
shaderc_get_transitive_libs(${target} all_libs)

set(libname
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${new_target}${CMAKE_STATIC_LIBRARY_SUFFIX})

if (MSVC)
string(REPLACE ";" ">;$<TARGET_FILE:" temp_string "${all_libs}")
set(lib_target_list "$<TARGET_FILE:${temp_string}>")

add_custom_command(OUTPUT ${libname}
DEPENDS ${all_libs}
COMMAND lib.exe ${lib_target_list} /OUT:${libname} /NOLOGO)
elseif(APPLE)
string(REPLACE ";" ">;$<TARGET_FILE:" temp_string "${all_libs}")
set(lib_target_list "$<TARGET_FILE:${temp_string}>")

add_custom_command(OUTPUT ${libname}
DEPENDS ${all_libs}
COMMAND libtool -static -o ${libname} ${lib_target_list})
else()
string(REPLACE ";" "> \naddlib $<TARGET_FILE:" temp_string "${all_libs}")
set(start_of_file
"create ${libname}\naddlib $<TARGET_FILE:${temp_string}>")
set(build_script_file "${start_of_file}\nsave\nend\n")

file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${new_target}.ar"
CONTENT ${build_script_file}
CONDITION 1)

add_custom_command(OUTPUT ${libname}
DEPENDS ${all_libs}
COMMAND ${CMAKE_AR} -M < ${new_target}.ar)
endif()

add_custom_target(${new_target}_genfile ALL
DEPENDS ${libname})

# CMake needs to be able to see this as another normal library,
# so import the newly created library as an imported library,
# and set up the dependencies on the custom target.
add_library(${new_target} STATIC IMPORTED)
set_target_properties(${new_target}
PROPERTIES IMPORTED_LOCATION ${libname})
add_dependencies(${new_target} ${new_target}_genfile)
add_library(${new_target} STATIC)
foreach(lib IN LISTS all_libs)
target_sources(${new_target} PRIVATE $<TARGET_OBJECTS:${lib}>)
endforeach()
endfunction()
2 changes: 1 addition & 1 deletion glslc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (SHADERC_ENABLE_WGSL_OUTPUT)
endif(SHADERC_ENABLE_WGSL_OUTPUT)

target_link_libraries(glslc PRIVATE
glslang OSDependent OGLCompiler HLSL glslang SPIRV # Glslang libraries
glslang SPIRV # Glslang libraries
$<$<BOOL:${SHADERC_ENABLE_WGSL_OUTPUT}>:libtint> # Tint libraries, optional
shaderc_util shaderc # internal Shaderc libraries
${CMAKE_THREAD_LIBS_INIT})
Expand Down
22 changes: 11 additions & 11 deletions glslc/test/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TestPoundVersion310InIncludingFile(
#line 1 "a.vert"

#line 1 "b.glsl"
void main(){ }
void main() { }
#line 3 "a.vert"

"""
Expand All @@ -61,7 +61,7 @@ class TestPoundVersion150InIncludingFile(
#line 0 "a.vert"

#line 0 "b.glsl"
void main(){ }
void main() { }
#line 2 "a.vert"

"""
Expand Down Expand Up @@ -138,7 +138,7 @@ class TestSpaceAroundPoundVersion310InIncludingFile(
#line 1 "a.vert"

#line 1 "b.glsl"
void main(){ }
void main() { }
#line 3 "a.vert"

"""
Expand All @@ -161,7 +161,7 @@ class TestSpaceAroundPoundVersion150InIncludingFile(
#line 0 "a.vert"

#line 0 "b.glsl"
void main(){ }
void main() { }
#line 2 "a.vert"

"""
Expand All @@ -183,7 +183,7 @@ class TestPoundLineWithForcedVersion310(
"""#extension GL_GOOGLE_include_directive : enable
#line 1 "a.vert"
#line 1 "b.glsl"
void main(){ }
void main() { }
#line 2 "a.vert"

"""
Expand All @@ -205,7 +205,7 @@ class TestPoundLineWithForcedVersion150(
"""#extension GL_GOOGLE_include_directive : enable
#line 0 "a.vert"
#line 0 "b.glsl"
void main(){ }
void main() { }
#line 1 "a.vert"

"""
Expand All @@ -230,7 +230,7 @@ class TestPoundLineWithForcedDifferentVersion(
#line 1 "a.vert"

#line 1 "b.glsl"
void main(){ }
void main() { }
#line 3 "a.vert"

"""
Expand Down Expand Up @@ -288,14 +288,14 @@ class TestExplicitPoundLineWithPoundInclude(
#line 1 "a.vert"

#line 10000 "injected.glsl"
int plus1(int a){ return a + 1;}
int plus1(int a) { return a + 1; }
#line 1 "inc.glsl"
int inc(int a){ return a + 1;}
int inc(int a) { return a + 1; }
#line 10002 "injected.glsl"
int plus2(int a){ return a + 2;}
int plus2(int a) { return a + 2; }
#line 55555
#line 1 "main.glsl"
void main(){
void main() {
gl_Position = vec4(1.);
}
#line 55556 "injected.glsl"
Expand Down
34 changes: 17 additions & 17 deletions glslc/test/option_dash_D.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class TestDashCapDWithDashE(expect.ReturnCodeIsZero,

expected_stdout = [
"""
void main(){ return 3;}
void main() { return 3; }
"""]

@inside_glslc_testsuite('OptionCapD')
Expand All @@ -239,18 +239,18 @@ class TestDashCapDWithDashEIfDef(expect.ReturnCodeIsZero,
#else
void f() { int x; }
#endif
void main(){ return 3;}
void main(){ return 3; }
""", '.vert')
glslc_args = ['-DX', '-E', '-std=450core', shader]

expected_stdout = [
"""

void f(){ }
void f() { }



void main(){ return 3;}
void main() { return 3; }
"""]

@inside_glslc_testsuite('OptionCapD')
Expand All @@ -265,7 +265,7 @@ class TestDashCapDWithDashEIfNDef(expect.ReturnCodeIsZero,
#else
void f() { int x; }
#endif
void main(){ return 3;}
void main(){ return 3; }
""", '.vert')
glslc_args = ['-DX', '-E', '-std=450core', shader]

Expand All @@ -274,9 +274,9 @@ class TestDashCapDWithDashEIfNDef(expect.ReturnCodeIsZero,



void f(){ int x;}
void f() { int x; }

void main(){ return 3;}
void main() { return 3; }
"""]


Expand All @@ -292,18 +292,18 @@ class TestDashCapDWithDashEEqIfDef(expect.ReturnCodeIsZero,
#else
void f() { int x; }
#endif
void main(){ return 3;}
void main() { return 3; }
""", '.vert')
glslc_args = ['-DX=', '-E', '-std=450core', shader]

expected_stdout = [
"""

void f(){ }
void f() { }



void main(){ return 3;}
void main() { return 3; }
"""]

@inside_glslc_testsuite('OptionCapD')
Expand All @@ -318,7 +318,7 @@ class TestDashCapDWithDashEEqIfNDef(expect.ReturnCodeIsZero,
#else
void f() { int x; }
#endif
void main(){ return 3;}
void main(){ return 3; }
""", '.vert')
glslc_args = ['-DX=', '-E', '-std=450core', shader]

Expand All @@ -327,9 +327,9 @@ class TestDashCapDWithDashEEqIfNDef(expect.ReturnCodeIsZero,



void f(){ int x;}
void f() { int x; }

void main(){ return 3;}
void main() { return 3; }
"""]

@inside_glslc_testsuite('OptionCapD')
Expand All @@ -339,13 +339,13 @@ class TestDashCapDWithDashEFunctionMacro(expect.ReturnCodeIsZero,

shader = FileShader(
"""
void main(){ return FOO(3);}
void main(){ return FOO(3); }
""", '.vert')
glslc_args = ['-DFOO(x)=(2*x+1)*x*x', '-E', '-std=450core', shader]

expected_stdout = [
"""
void main(){ return(2 * 3 + 1)* 3 * 3;}
void main() { return(2 * 3 + 1) * 3 * 3; }
"""]

@inside_glslc_testsuite('OptionCapD')
Expand All @@ -355,11 +355,11 @@ class TestDashCapDWithDashENestedMacro(expect.ReturnCodeIsZero,

shader = FileShader(
"""
void main(){ return X;}
void main() { return X; }
""", '.vert')
glslc_args = ['-DY=4', '-DX=Y', '-E', '-std=450core', shader]

expected_stdout = [
"""
void main(){ return 4;}
void main() { return 4; }
"""]
Loading
Loading