support clang and other compilers
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
// C compiler
|
// C compiler
|
||||||
const char* CC = "gcc";
|
const char* CC = "cc";
|
||||||
|
|
||||||
// C++ compiler
|
// C++ compiler
|
||||||
const char* CXX = "g++";
|
const char* CXX = "c++";
|
||||||
|
|
||||||
|
// The compilation options are chosen with gcc in mind, but clang should also work
|
||||||
|
// Other compilers are not tested, but may work
|
||||||
// You can read about gcc options by running "man gcc"
|
// You can read about gcc options by running "man gcc"
|
||||||
|
|
||||||
// Compiler options to use...
|
// Compiler options to use...
|
||||||
|
|
||||||
// ...when debugging
|
// ...when debugging
|
||||||
@@ -14,7 +17,7 @@ const char* CXX = "g++";
|
|||||||
#define RELEASE_FLAGS "-Ofast", "-s"
|
#define RELEASE_FLAGS "-Ofast", "-s"
|
||||||
|
|
||||||
// ...for both C and C++
|
// ...for both C and C++
|
||||||
#define CPPFLAGS "--whole-program", "-march=native", "-Wall", "-Wextra", "-pipe"
|
#define CPPFLAGS "-fwhole-program", "-march=native", "-Wall", "-Wextra", "-pipe"
|
||||||
|
|
||||||
// ...for C
|
// ...for C
|
||||||
#define CFLAGS CPPFLAGS
|
#define CFLAGS CPPFLAGS
|
||||||
|
|||||||
+3
-2
@@ -7,9 +7,10 @@ PREFIX=/usr/local
|
|||||||
|
|
||||||
|
|
||||||
# Compile cppipe
|
# Compile cppipe
|
||||||
options="-std=c++17 -Ofast --whole-program -march=native -DNDEBUG -Wall -Wextra -Wno-parentheses -Wno-unused-result -s -pipe"
|
# The options are with gcc in mind, but should work with clang and maybe other compilers
|
||||||
|
options="-std=c++17 -Ofast -fwhole-program -march=native -DNDEBUG -Wall -Wextra -Wno-parentheses -Wno-unused-result -s -pipe"
|
||||||
# options="-std=c++17 -g"
|
# options="-std=c++17 -g"
|
||||||
g++ -o cppipe $options cppipe.cpp
|
c++ -o cppipe $options cppipe.cpp
|
||||||
chmod 755 cppipe
|
chmod 755 cppipe
|
||||||
mv cppipe ${PREFIX}/bin
|
mv cppipe ${PREFIX}/bin
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
struct MappedFile // todo: move to utils
|
struct MappedFile // todo: move to utils
|
||||||
{
|
{
|
||||||
// ~MappedFile()
|
// ~MappedFile()
|
||||||
@@ -55,6 +58,8 @@ fs::path src_file;
|
|||||||
fs::path cache_dir;
|
fs::path cache_dir;
|
||||||
fs::path bin; // cache bins to avoid recompiles
|
fs::path bin; // cache bins to avoid recompiles
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int src_arg = parse_args_until_src(argc, argv);
|
int src_arg = parse_args_until_src(argc, argv);
|
||||||
@@ -81,6 +86,9 @@ int main(int argc, char* argv[])
|
|||||||
exec(run);
|
exec(run);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
int parse_args_until_src(int argc, char* argv[])
|
int parse_args_until_src(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
@@ -285,3 +293,5 @@ bool is_src_file(const string_view p)
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user