diff options
-rw-r--r-- | backend/ninja/Ninja.cpp | 4 | ||||
-rw-r--r-- | include/Conf.hpp | 3 | ||||
-rw-r--r-- | src/CmakeModule.cpp | 8 | ||||
-rw-r--r-- | src/main.cpp | 68 |
4 files changed, 48 insertions, 35 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 980ef2c..8b815cb 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -412,6 +412,8 @@ namespace backend return ninja::NinjaArg::createRaw("-fsanitize=undefined"); case Sanitize::LEAK: return ninja::NinjaArg::createRaw("-fsanitize=leak"); + case Sanitize::THREAD: + return ninja::NinjaArg::createRaw("-fsanitize=thread"); } } return {}; @@ -427,6 +429,8 @@ namespace backend return ninja::NinjaArg::createRaw("-lubsan"); case Sanitize::LEAK: return ninja::NinjaArg::createRaw("-llsan"); + case Sanitize::THREAD: + return ninja::NinjaArg::createRaw("-ltsan"); } return {}; } diff --git a/include/Conf.hpp b/include/Conf.hpp index 2ec3148..dbe89d4 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -204,7 +204,8 @@ namespace sibs NONE, ADDRESS, UNDEFINED, - LEAK + LEAK, + THREAD }; const Sanitize SANITIZE_INVALID = (Sanitize)-1; diff --git a/src/CmakeModule.cpp b/src/CmakeModule.cpp index f57a8cf..5bf9400 100644 --- a/src/CmakeModule.cpp +++ b/src/CmakeModule.cpp @@ -80,7 +80,7 @@ namespace sibs case Sanitize::NONE: break; case Sanitize::ADDRESS: - allLinkerFlags += " -lasan"; + allLinkerFlags += TINYDIR_STRING(" -lasan"); break; case Sanitize::UNDEFINED: allLinkerFlags += TINYDIR_STRING(" -lubsan"); @@ -88,6 +88,9 @@ namespace sibs case Sanitize::LEAK: allLinkerFlags += TINYDIR_STRING(" -llsan"); break; + case Sanitize::THREAD: + allLinkerFlags += TINYDIR_STRING(" -ltsan"); + break; } } @@ -212,6 +215,9 @@ namespace sibs case Sanitize::LEAK: cflags += TINYDIR_STRING(" -fsanitize=leak"); break; + case Sanitize::THREAD: + cflags += TINYDIR_STRING(" -fsanitize=thread"); + break; } } diff --git a/src/main.cpp b/src/main.cpp index 0a70d36..cc1f4a5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,25 +117,25 @@ static void usage() printf("Usage: sibs COMMAND\n\n"); printf("Simple Build System for Native Languages\n\n"); printf("Commands:\n"); - printf(" build\t\tBuild a project that contains a project.conf file\n"); - printf(" new\t\tCreate a new project\n"); - printf(" init\t\tInitialize project in an existing directory\n"); - printf(" test\t\tBuild and run tests for a sibs project\n"); - printf(" package\t\tCreate a redistributable package from a sibs project. Note: Redistributable packages can't use system packages to build\n"); - printf(" platform\t\tPrint name of platform (to stdout) and exit\n"); - printf(" platforms\t\tPrint list of supported platforms (to stdout) and exit\n"); + printf(" build Build a project that contains a project.conf file\n"); + printf(" new Create a new project\n"); + printf(" init Initialize project in an existing directory\n"); + printf(" test Build and run tests for a sibs project\n"); + printf(" package Create a redistributable package from a sibs project. Note: Redistributable packages can't use system packages to build\n"); + printf(" platform Print name of platform (to stdout) and exit\n"); + printf(" platforms Print list of supported platforms (to stdout) and exit\n"); exit(1); } static void usageBuild() { - printf("Usage: sibs build [project_path] [--debug|--release] [--sanitize=(address|undefined|leak|none)] [--platform <platform>]\n\n"); + printf("Usage: sibs build [project_path] [--debug|--release] [--sanitize=(address|undefined|leak|thread|none)] [--platform <platform>]\n\n"); printf("Build a sibs project\n\n"); printf("Options:\n"); - printf(" project_path\t\tThe directory containing a project.conf file - Optional (default: current directory)\n"); - printf(" --debug|--release\t\tOptimization level to build project and dependencies with (if not a system package) - Optional (default: --debug)\n"); - printf(" --sanitize\t\tAdd runtime address/undefined behavior sanitization. Program can be up to 3 times slower and use 10 times as much RAM. Ignored if compiler doesn't support sanitization - Optional (default: none)\n"); - printf(" --platform\t\tThe platform to build for - Optional (default: the running platform)\n"); + printf(" project_path The directory containing a project.conf file - Optional (default: current directory)\n"); + printf(" --debug|--release Optimization level to build project and dependencies with (if not a system package) - Optional (default: --debug)\n"); + printf(" --sanitize Add runtime address/undefined behavior sanitization. Program can be up to 3 times slower and use 10 times as much RAM. Ignored if compiler doesn't support sanitization - Optional (default: none)\n"); + printf(" --platform The platform to build for - Optional (default: the running platform)\n"); printf("Examples:\n"); printf(" sibs build\n"); printf(" sibs build dirA/dirB\n"); @@ -151,11 +151,11 @@ static void usageNew() printf("Usage: sibs new <project_name> <--exec|--static|--dynamic> [--lang c|c++|zig]\n\n"); printf("Create a new sibs project\n\n"); printf("Options:\n"); - printf(" project_name\t\tThe name of the project you want to create\n"); - printf(" --exec\t\t\tProject compiles to an executable\n"); - printf(" --static\t\t\tProject compiles to a static library\n"); - printf(" --dynamic\t\t\tProject compiles to a dynamic library\n"); - printf(" --lang\t\t\tProject template language - Optional (default: c++)\n"); + printf(" project_name The name of the project you want to create\n"); + printf(" --exec Project compiles to an executable\n"); + printf(" --static Project compiles to a static library\n"); + printf(" --dynamic Project compiles to a dynamic library\n"); + printf(" --lang Project template language - Optional (default: c++)\n"); printf("Examples:\n"); printf(" sibs new hello_world --exec\n"); exit(1); @@ -163,13 +163,13 @@ static void usageNew() static void usageTest() { - printf("Usage: sibs test [project_path] [--sanitize=(address|undefined|leak|none)] [--file <filepath>...|--all-files]\n\n"); + printf("Usage: sibs test [project_path] [--sanitize=(address|undefined|leak|thread|none)] [--file <filepath>...|--all-files]\n\n"); printf("Build and run tests for a sibs project\n\n"); printf("Options:\n"); - printf(" project_path\t\tThe directory containing a project.conf file - Optional (default: current directory)\n"); - printf(" --sanitize\t\tAdd runtime address/undefined behavior sanitization. Program can be up to 3 times slower and use 10 times as much RAM. Ignored if compiler doesn't support sanitization - Optional (default: address)\n"); - printf(" --file\t\t\tSpecify file to test, path to test file should be defined after this. Can be defined multiple times to test multiple files - Optional (default: not used), Only applicable for Zig\n"); - printf(" --all-files\t\t\tTest all files - Optional (default: not used), Only applicable for Zig\n"); + printf(" project_path The directory containing a project.conf file - Optional (default: current directory)\n"); + printf(" --sanitize Add runtime address/undefined behavior sanitization. Program can be up to 3 times slower and use 10 times as much RAM. Ignored if compiler doesn't support sanitization - Optional (default: address)\n"); + printf(" --file Specify file to test, path to test file should be defined after this. Can be defined multiple times to test multiple files - Optional (default: not used), Only applicable for Zig\n"); + printf(" --all-files Test all files - Optional (default: not used), Only applicable for Zig\n"); printf("Examples:\n"); printf(" sibs test\n"); printf(" sibs test dirA/dirB\n"); @@ -184,11 +184,11 @@ static void usageInit() printf("Usage: sibs init [project_path] <--exec|--static|--dynamic> [--lang c|c++|zig]\n\n"); printf("Create sibs project structure in an existing directory\n\n"); printf("Options:\n"); - printf(" project_path\t\tThe directory where you want to initialize sibs project - Optional (default: current directory)\n"); - printf(" --exec\t\t\tProject compiles to an executable\n"); - printf(" --static\t\t\tProject compiles to a static library\n"); - printf(" --dynamic\t\t\tProject compiles to a dynamic library\n"); - printf(" --lang\t\t\tProject template language - Optional (default: c++)\n"); + printf(" project_path The directory where you want to initialize sibs project - Optional (default: current directory)\n"); + printf(" --exec Project compiles to an executable\n"); + printf(" --static Project compiles to a static library\n"); + printf(" --dynamic Project compiles to a dynamic library\n"); + printf(" --lang Project template language - Optional (default: c++)\n"); printf("Examples:\n"); printf(" sibs init . --exec\n"); printf(" sibs init dirA/dirB --dynamic\n"); @@ -200,10 +200,10 @@ static void usagePackage() printf("Usage: sibs package [project_path] <--static|--bundle|--bundle-install>\n\n"); printf("Create a redistributable package from a sibs project. Note: Redistributable packages can't use system packages to build if packaging using --static\n\n"); printf("Options:\n"); - printf(" project_path\t\tThe directory containiung a project.conf file - Optional (default: current directory)\n"); - printf(" --static\t\tPackage project by building everything statically. Note: can't use system packages when using this option (meaning no pkg-config support)\n\n"); - printf(" --bundle\t\tPackage project by copying all dynamic libraries into one location and creating an archive of all files. The executable is patched to use the dynamic libraries in the same directory. Note: if your project loads dynamic libraries at runtime (for example using dlopen) then you need to manually copy those libraries to the archive\n\n"); - printf(" --bundle-install\t\tPackage project by copying all dynamic libraries into one location, except libraries that can automatically be downloaded online by the user. Then create an archive of all files - Use this option if you want to reduce the size of the distributed package and also if user already has some of the libraries installed/downloaded on their system, then they are used." + printf(" project_path The directory containiung a project.conf file - Optional (default: current directory)\n"); + printf(" --static Package project by building everything statically. Note: can't use system packages when using this option (meaning no pkg-config support)\n\n"); + printf(" --bundle Package project by copying all dynamic libraries into one location and creating an archive of all files. The executable is patched to use the dynamic libraries in the same directory. Note: if your project loads dynamic libraries at runtime (for example using dlopen) then you need to manually copy those libraries to the archive\n\n"); + printf(" --bundle-install Package project by copying all dynamic libraries into one location, except libraries that can automatically be downloaded online by the user. Then create an archive of all files - Use this option if you want to reduce the size of the distributed package and also if user already has some of the libraries installed/downloaded on their system, then they are used." "Note: if your project loads dynamic libraries at runtime (for example using dlopen) then you need to manually copy those libraries to the archive"); printf("Examples:\n"); printf(" sibs package --static\n"); @@ -457,6 +457,8 @@ static Sanitize sanitize_string_to_type(const _tinydir_char_t *str) { return Sanitize::UNDEFINED; else if(strcmp(str, TINYDIR_STRING("leak")) == 0) return Sanitize::LEAK; + else if(strcmp(str, TINYDIR_STRING("thread")) == 0) + return Sanitize::THREAD; else if(strcmp(str, TINYDIR_STRING("none")) == 0) return Sanitize::NONE; else @@ -495,7 +497,7 @@ static int buildProject(int argc, const _tinydir_char_t **argv) { sanitize = sanitize_string_to_type(arg + 11); if(sanitize == SANITIZE_INVALID) { - ferr << "Error: Invalid sanitize option " << (arg + 11) << ", expected address, undefined, leak or none" << endl; + ferr << "Error: Invalid sanitize option " << (arg + 11) << ", expected address, undefined, leak, thread or none" << endl; usageBuild(); } } @@ -613,7 +615,7 @@ static int testProject(int argc, const _tinydir_char_t **argv) { sanitize = sanitize_string_to_type(arg + 11); if(sanitize == SANITIZE_INVALID) { - ferr << "Error: Invalid sanitize option " << (arg + 11) << ", expected address, undefined, leak or none" << endl; + ferr << "Error: Invalid sanitize option " << (arg + 11) << ", expected address, undefined, leak, thread or none" << endl; usageTest(); } } |