summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-09-12 16:38:39 -0400
committerGitHub <noreply@github.com>2019-09-12 16:38:39 -0400
commit33f95e0e3d41262a6ebe023b2b2624d735539c6d (patch)
treed05c09cced0a539ec1da3ebfe159e5a5f478ac65
parentbde858b31ac99b84ffba546d1022b34bb4621d49 (diff)
Fix problems with x86 CPU tests (#1051)
* Try to make x86 builds on x86 platforms (not the default for the os). * Use c style include for stdint.h cos not found on x86 linux. * Simplified x86 issue for linux. * Fix typo. * Remove the need for the shared-library category. * Disable CPU tests on linux x86. * Fix typo. * Named test requirement methods so overloading not confusing (around flags, and SlangPassThroughType which are both 'int')
-rw-r--r--source/core/slang-common.h2
-rw-r--r--source/core/slang-gcc-compiler-util.cpp14
-rw-r--r--tests/cpp-compiler/c-compile-pass-through-shared-library.c2
-rw-r--r--tests/cpp-compiler/cpp-compile-shared-library.cpp2
-rw-r--r--tests/cross-compile/cpp-resource.slang2
-rw-r--r--tools/slang-test/slang-test-main.cpp54
-rw-r--r--tools/slang-test/test-context.h15
7 files changed, 63 insertions, 28 deletions
diff --git a/source/core/slang-common.h b/source/core/slang-common.h
index 7d8568642..717b63740 100644
--- a/source/core/slang-common.h
+++ b/source/core/slang-common.h
@@ -5,7 +5,7 @@
#include <assert.h>
-#include <cstdint>
+#include <stdint.h>
#ifdef __GNUC__
#define CORE_LIB_ALIGN_16(x) x __attribute__((aligned(16)))
diff --git a/source/core/slang-gcc-compiler-util.cpp b/source/core/slang-gcc-compiler-util.cpp
index 21b55e686..3c4c4ec15 100644
--- a/source/core/slang-gcc-compiler-util.cpp
+++ b/source/core/slang-gcc-compiler-util.cpp
@@ -407,6 +407,20 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
cmdLine.addArg("-std=c++14");
}
+ // TODO(JS): Here we always set -m32 on x86. It could be argued it is only necessary when creating a shared library
+ // but if we create an object file, we don't know what to choose because we don't know what final usage is.
+ // It could also be argued that the platformKind could define the actual desired target - but as it stands
+ // we only have a target of 'Linux' (as opposed to Win32/64). Really it implies we need an arch enumeration too.
+ //
+ // For now we just make X86 binaries try and produce x86 compatible binaries as fixes the immediate problems.
+#if SLANG_PROCESSOR_X86
+ /* Used to specify the processor more broadly. For a x86 binary we need to make sure we build x86 builds
+ even when on an x64 system.
+ -m32
+ -m64*/
+ cmdLine.addArg("-m32");
+#endif
+
switch (options.optimizationLevel)
{
case OptimizationLevel::None:
diff --git a/tests/cpp-compiler/c-compile-pass-through-shared-library.c b/tests/cpp-compiler/c-compile-pass-through-shared-library.c
index 9f33bc430..143817325 100644
--- a/tests/cpp-compiler/c-compile-pass-through-shared-library.c
+++ b/tests/cpp-compiler/c-compile-pass-through-shared-library.c
@@ -1,4 +1,4 @@
-//TEST(smoke,shared-library):CPP_COMPILER_COMPILE: -pass-through c -entry test -target callable
+//TEST(smoke):CPP_COMPILER_COMPILE: -pass-through c -entry test -target callable
#include <stdlib.h>
#include <stdio.h>
diff --git a/tests/cpp-compiler/cpp-compile-shared-library.cpp b/tests/cpp-compiler/cpp-compile-shared-library.cpp
index 5341cd2fb..c802a57cd 100644
--- a/tests/cpp-compiler/cpp-compile-shared-library.cpp
+++ b/tests/cpp-compiler/cpp-compile-shared-library.cpp
@@ -1,4 +1,4 @@
-//TEST(smoke,shared-library):CPP_COMPILER_SHARED_LIBRARY:
+//TEST(smoke):CPP_COMPILER_SHARED_LIBRARY:
#include <stdlib.h>
#include <stdio.h>
diff --git a/tests/cross-compile/cpp-resource.slang b/tests/cross-compile/cpp-resource.slang
index 9a48085df..b12623339 100644
--- a/tests/cross-compile/cpp-resource.slang
+++ b/tests/cross-compile/cpp-resource.slang
@@ -1,4 +1,4 @@
-//TEST(shared-library):CPP_COMPILER_COMPILE: -profile cs_5_0 -entry computeMain -target callable
+//TEST:CPP_COMPILER_COMPILE: -profile cs_5_0 -entry computeMain -target callable
struct Thing
{
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 3b14b353b..42b9e9331 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -711,11 +711,11 @@ static SlangResult _extractRenderTestRequirements(const CommandLine& cmdLine, Te
}
else
{
- ioRequirements->addUsed(passThru);
+ ioRequirements->addUsedBackEnd(passThru);
}
// Add the render api used
- ioRequirements->addUsed(renderApiType);
+ ioRequirements->addUsedRenderApi(renderApiType);
return SLANG_OK;
}
@@ -728,7 +728,7 @@ static SlangResult _extractSlangCTestRequirements(const CommandLine& cmdLine, Te
String passThrough;
if (SLANG_SUCCEEDED(_extractArg(cmdLine, "-pass-through", passThrough)))
{
- ioRequirements->addUsed(_toPassThroughType(passThrough.getUnownedSlice()));
+ ioRequirements->addUsedBackEnd(_toPassThroughType(passThrough.getUnownedSlice()));
}
}
@@ -802,6 +802,11 @@ static RenderApiFlags _getAvailableRenderApiFlags(TestContext* context)
if (apiType == RenderApiType::CPU)
{
+ if ((context->availableBackendFlags & PassThroughFlag::Generic_C_CPP) == 0)
+ {
+ continue;
+ }
+
// Check that the session has the generic C/CPP compiler availability - which is all we should need for CPU target
if (SLANG_SUCCEEDED(spSessionCheckPassThroughSupport(context->getSession(), SLANG_PASS_THROUGH_GENERIC_C_CPP)))
{
@@ -1420,6 +1425,7 @@ static TestResult runCPPCompilerSharedLibrary(TestContext* context, TestInput& i
// If we are just collecting requirements, say it passed
if (context->isCollectingRequirements())
{
+ context->testRequirements->addUsedBackEnd(SLANG_PASS_THROUGH_GENERIC_C_CPP);
return TestResult::Pass;
}
@@ -1535,6 +1541,7 @@ static TestResult runCPPCompilerExecute(TestContext* context, TestInput& input)
// If we are just collecting requirements, say it passed
if (context->isCollectingRequirements())
{
+ context->testRequirements->addUsedBackEnd(SLANG_PASS_THROUGH_GENERIC_C_CPP);
return TestResult::Pass;
}
@@ -2848,6 +2855,22 @@ void runTestsInDirectory(
}
}
+static void _disableCPPBackends(TestContext* context)
+{
+ const SlangPassThrough cppPassThrus[] =
+ {
+ SLANG_PASS_THROUGH_GENERIC_C_CPP,
+ SLANG_PASS_THROUGH_VISUAL_STUDIO,
+ SLANG_PASS_THROUGH_CLANG,
+ SLANG_PASS_THROUGH_GCC,
+ };
+
+ for (auto passThru : cppPassThrus)
+ {
+ context->availableBackendFlags &= ~(PassThroughFlags(1) << int(passThru));
+ }
+}
+
SlangResult innerMain(int argc, char** argv)
{
@@ -2870,8 +2893,7 @@ SlangResult innerMain(int argc, char** argv)
auto vulkanTestCategory = categorySet.add("vulkan", fullTestCategory);
auto unitTestCatagory = categorySet.add("unit-test", fullTestCategory);
auto compatibilityIssueCategory = categorySet.add("compatibility-issue", fullTestCategory);
- auto sharedLibraryCategory = categorySet.add("shared-library", fullTestCategory);
-
+
#if SLANG_WINDOWS_FAMILY
auto windowsCategory = categorySet.add("windows", fullTestCategory);
#endif
@@ -2883,7 +2905,6 @@ SlangResult innerMain(int argc, char** argv)
// An un-categorized test will always belong to the `full` category
categorySet.defaultCategory = fullTestCategory;
-
TestCategory* fxcCategory = nullptr;
TestCategory* dxcCategory = nullptr;
TestCategory* glslangCategory = nullptr;
@@ -2928,6 +2949,16 @@ SlangResult innerMain(int argc, char** argv)
Options& options = context.options;
+ if (options.outputMode == TestOutputMode::TeamCity)
+ {
+ // On TeamCity CI there is an issue with unix/linux targets where test system may be different from the build system
+ // That we rely on having compilation tools present such that on x64 systems we can build x86 binaries, and that appears to
+ // not be the case.
+#if SLANG_UNIX_FAMILY && SLANG_PROCESSOR_X86
+ _disableCPPBackends(&context);
+#endif
+ }
+
if (options.subCommand.getLength())
{
// Get the function from the tool
@@ -2950,17 +2981,6 @@ SlangResult innerMain(int argc, char** argv)
return func(StdWriters::getSingleton(), context.getSession(), int(args.getCount()), args.getBuffer());
}
- // On TeamCity CI there is an issue with unix/linux targets where test system may be different from the build system
- // That when C/C++ code is compiled, it does so for the test systems arch not for the build system
- // This leads to shared library not being loadable, so we need to disable such tests that have this requirement
- if (options.outputMode == TestOutputMode::TeamCity)
- {
-#if SLANG_UNIX_FAMILY && SLANG_PROCESSOR_X86
- // Disable shared library requiring tests
- options.excludeCategories.Add(sharedLibraryCategory, sharedLibraryCategory);
-#endif
- }
-
if( options.includeCategories.Count() == 0 )
{
options.includeCategories.Add(fullTestCategory, fullTestCategory);
diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h
index 66486e7bc..a9f3cec25 100644
--- a/tools/slang-test/test-context.h
+++ b/tools/slang-test/test-context.h
@@ -32,20 +32,21 @@ struct PassThroughFlag
/// back-end availability
struct TestRequirements
{
- TestRequirements& addUsed(SlangPassThrough type)
+
+ TestRequirements& addUsedRenderApi(Slang::RenderApiType type)
{
- if (type != SLANG_PASS_THROUGH_NONE)
+ using namespace Slang;
+ if (type != RenderApiType::Unknown)
{
- usedBackendFlags |= PassThroughFlags(1) << int(type);
+ usedRenderApiFlags |=RenderApiFlags(1) << int(type);
}
return *this;
}
- TestRequirements& addUsed(Slang::RenderApiType type)
+ TestRequirements& addUsedBackEnd(SlangPassThrough type)
{
- using namespace Slang;
- if (type != RenderApiType::Unknown)
+ if (type != SLANG_PASS_THROUGH_NONE)
{
- usedRenderApiFlags |=RenderApiFlags(1) << int(type);
+ usedBackendFlags |= PassThroughFlags(1) << int(type);
}
return *this;
}