-
Notifications
You must be signed in to change notification settings - Fork 379
Fix SLANG_ENABLE_ASAN CMake option
#9108
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
base: master
Are you sure you want to change the base?
Changes from all commits
8922141
4dae658
7e8a478
53b5d33
ffd7a0e
9fe3e02
506d457
817f6db
0a30070
3d46bc2
d688ef3
bc306b7
6261017
fa1982c
39971df
b4a3193
5464944
6076e54
1d870d6
799a19a
03c725f
f3630e2
d33b400
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -375,8 +375,7 @@ static SlangResult _parseGCCFamilyLine( | |
|
|
||
| SliceAllocator allocator; | ||
|
|
||
| diagnostics->reset(); | ||
| diagnostics->setRaw(SliceUtil::asCharSlice(exeRes.standardError)); | ||
| diagnostics->appendRaw(SliceUtil::asCharSlice(exeRes.standardError)); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
|
|
||
| // We hold in workDiagnostics so as it is more convenient to append to the last with a | ||
| // continuation also means we don't hold the allocations of building up continuations, just the | ||
|
|
@@ -603,12 +602,6 @@ static SlangResult _parseGCCFamilyLine( | |
| { | ||
| // Shared library | ||
| cmdLine.addArg("-shared"); | ||
|
|
||
| if (PlatformUtil::isFamily(PlatformFamily::Unix, platformKind)) | ||
| { | ||
| // Position independent | ||
| cmdLine.addArg("-fPIC"); | ||
| } | ||
| break; | ||
| } | ||
| case SLANG_HOST_EXECUTABLE: | ||
|
|
@@ -620,12 +613,33 @@ static SlangResult _parseGCCFamilyLine( | |
| { | ||
| // Don't link, just produce object file | ||
| cmdLine.addArg("-c"); | ||
|
|
||
| break; | ||
| } | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
| if (PlatformUtil::isFamily(PlatformFamily::Unix, platformKind)) | ||
| { | ||
| // Position independent | ||
| cmdLine.addArg("-fPIC"); | ||
| } | ||
|
Comment on lines
+623
to
+627
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initial discussion: https://github.com/shader-slang/slang/pull/8980/files#r2528348258. GCC used to emit the following warning when using See gcc-mirror/gcc@0a1d992. I assume that's why this was restricted to |
||
|
|
||
| #if defined(__has_feature) | ||
| #if __has_feature(address_sanitizer) | ||
| if (options.targetType != SLANG_OBJECT_CODE) | ||
| { | ||
| #if SLANG_CLANG || SLANG_GCC | ||
| cmdLine.addArg("-fsanitize=address"); | ||
| #endif | ||
| #if SLANG_CLANG | ||
| cmdLine.addArg("-shared-libsan"); | ||
| #endif | ||
| } | ||
| #endif | ||
| #endif | ||
|
|
||
| // Add defines | ||
| for (const auto& define : options.defines) | ||
| { | ||
|
|
@@ -711,13 +725,17 @@ static SlangResult _parseGCCFamilyLine( | |
| const UnownedStringSlice path(fileRep->getPath()); | ||
| libPathPool.add(Path::getParentDirectory(path)); | ||
|
|
||
| cmdLine.addPrefixPathArg( | ||
| "-l", | ||
| ArtifactDescUtil::getBaseNameFromPath(artifact->getDesc(), path)); | ||
| if (options.targetType != SLANG_OBJECT_CODE) | ||
| { | ||
| cmdLine.addPrefixPathArg( | ||
| "-l", | ||
| ArtifactDescUtil::getBaseNameFromPath(artifact->getDesc(), path)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (options.sourceLanguage == SLANG_SOURCE_LANGUAGE_CPP && | ||
| options.targetType != SLANG_OBJECT_CODE && | ||
| !PlatformUtil::isFamily(PlatformFamily::Windows, platformKind)) | ||
| { | ||
| // Make STD libs available | ||
|
|
@@ -728,9 +746,12 @@ static SlangResult _parseGCCFamilyLine( | |
|
|
||
| for (const auto& libPath : libPathPool.getAdded()) | ||
| { | ||
| // Note that any escaping of the path is handled in the ProcessUtil:: | ||
| cmdLine.addArg("-L"); | ||
| cmdLine.addArg(libPath); | ||
| if (options.targetType != SLANG_OBJECT_CODE) | ||
| { | ||
| // Note that any escaping of the path is handled in the ProcessUtil:: | ||
| cmdLine.addArg("-L"); | ||
| cmdLine.addArg(libPath); | ||
| } | ||
| cmdLine.addArg("-F"); | ||
| cmdLine.addArg(libPath); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -467,7 +467,11 @@ class SLANG_RT_API String | |
| friend class StringBuilder; | ||
|
|
||
| private: | ||
| char* getData() const { return m_buffer ? m_buffer->getData() : (char*)""; } | ||
| char* getData() const | ||
| { | ||
| static char empty[] = ""; | ||
| return m_buffer ? m_buffer->getData() : empty; | ||
| } | ||
|
Comment on lines
-470
to
+474
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initial discussion: https://github.com/shader-slang/slang/pull/8980/files#r2518762552. |
||
|
|
||
|
|
||
| void ensureUniqueStorageWithCapacity(Index capacity); | ||
|
|
@@ -658,7 +662,11 @@ class SLANG_RT_API String | |
| #endif | ||
| } | ||
| } | ||
| bool operator==(const char* strbuffer) const { return (strcmp(begin(), strbuffer) == 0); } | ||
| bool operator==(const char* strbuffer) const | ||
| { | ||
| const char* volatile b = begin(); | ||
| return (strcmp(b, strbuffer) == 0); | ||
| } | ||
|
Comment on lines
-661
to
+669
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initial discussion: https://github.com/shader-slang/slang/pull/8980/files#r2518778200. |
||
|
|
||
| bool operator==(const String& str) const { return (strcmp(begin(), str.begin()) == 0); } | ||
| bool operator!=(const char* strbuffer) const { return (strcmp(begin(), strbuffer) != 0); } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be better to raise a
FATAL_ERROR(which stops CMake generation) as users might not notice a warning. SinceSLANG_ENABLE_ASANdefaults toOFFI think it's safe to assume that it beingONimplies the user really doesn't want Slang being built without sanitizers.