From ddccd48291538fa94996e97d54d0bf1d9272e4b6 Mon Sep 17 00:00:00 2001 From: Kevin Bogusch Date: Mon, 23 Dec 2024 08:17:25 -0500 Subject: [PATCH 1/8] Check for appropriate C compiler --- week4/day4.ipynb | 136 +++++++++++++++++++++++++++++++++++++++++++++-- week4/optimized | Bin 36920 -> 0 bytes 2 files changed, 132 insertions(+), 4 deletions(-) delete mode 100755 week4/optimized diff --git a/week4/day4.ipynb b/week4/day4.ipynb index 0df69a1..f140b92 100644 --- a/week4/day4.ipynb +++ b/week4/day4.ipynb @@ -453,6 +453,110 @@ "ui.launch(inbrowser=True)" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "e42286bc-085c-45dc-b101-234308e58269", + "metadata": {}, + "outputs": [], + "source": [ + "import platform\n", + "\n", + "VISUAL_STUDIO_2022_TOOLS = \"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Community\\\\Common7\\Tools\\\\VsDevCmd.bat\"\n", + "VISUAL_STUDIO_2019_TOOLS = \"C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\2019\\\\BuildTools\\\\Common7\\\\Tools\\\\VsDevCmd.bat\"\n", + "\n", + "simple_cpp = \"\"\"\n", + "#include \n", + "\n", + "int main() {\n", + " std::cout << \"Hello\";\n", + " return 0;\n", + "}\n", + "\"\"\"\n", + "\n", + "def run_cmd(command_to_run):\n", + " try:\n", + " run_result = subprocess.run(command_to_run, check=True, text=True, capture_output=True)\n", + " return run_result.stdout\n", + " except:\n", + " return \"\"\n", + "\n", + "def c_compiler_cmd(filename_base):\n", + "\n", + " with open(\"simple.cpp\", \"w\") as f:\n", + " f.write(simple_cpp)\n", + "\n", + " \n", + " my_platform = platform.system()\n", + " my_compiler = []\n", + " \n", + " \n", + " if my_platform == \"Windows\":\n", + " if os.path.isfile(VISUAL_STUDIO_2022_TOOLS):\n", + " if os.path.isfile(\"./simple.exe\"):\n", + " os.remove(\"./simple.exe\")\n", + " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Windows\", \"Visual Studio 2022\", [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", + " \n", + " if not my_compiler:\n", + " if os.path.isfile(VISUAL_STUDIO_2019_TOOLS):\n", + " if os.path.isfile(\"./simple.exe\"):\n", + " os.remove(\"./simple.exe\")\n", + " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Windows\", \"Visual Studio 2019\", [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", + "\n", + " if not my_compiler:\n", + " if os.path.isfile(\"./simple.exe\"):\n", + " os.remove(\"./simple.exe\")\n", + " compile_cmd = [\"cmd\", \"/c\", \"gcc\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " print(\"here\")\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Windows\", \"GCC\", [\"cmd\", \"/c\", \"gcc\", f\"{filename_base}.cpp\"]]\n", + "\n", + " if not my_compiler:\n", + " my_compiler=[my_platform, \"Unknown\", []]\n", + " \n", + " elif my_platform == \"Linux\":\n", + " if os.path.isfile(\"./simple\"):\n", + " os.remove(\"./simple\")\n", + " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Linux\", \"GCC\", [\"gcc\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", + "\n", + " if not my_compiler:\n", + " if os.path.isfile(\"./simple\"):\n", + " os.remove(\"./simple\")\n", + " compile_cmd = [\"clang\", \"simple.cpp\", \"-o\", \"simple\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Linux\", \"CLang\", [\"clang\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", + " \n", + " if not my_compiler:\n", + " my_compiler=[my_platform, \"Unknown\", []]\n", + "\n", + " elif my_platform == \"Darwin\":\n", + " if os.path.isfile(\"./simple\"):\n", + " os.remove(\"./simple\")\n", + " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Linux\", \"CLang\", [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", f\"{filename_base}\", f\"{filename_base}.cpp\"]]\n", + "\n", + " if not my_compiler:\n", + " my_compiler=[my_platform, \"Unknown\", []]\n", + "\n", + " if my_compiler:\n", + " return my_compiler\n", + " else:\n", + " return [\"Unknown\", \"Unknown\", []]\n" + ] + }, { "cell_type": "code", "execution_count": null, @@ -479,9 +583,9 @@ "source": [ "def execute_cpp(code):\n", " write_output(code)\n", + " print(f\"DEBUG. execute_cpp. compiler_cmd[2]=\\\"{compiler_cmd[2]}\\\"\")\n", " try:\n", - " compile_cmd = [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", \"optimized\", \"optimized.cpp\"]\n", - " compile_result = subprocess.run(compile_cmd, check=True, text=True, capture_output=True)\n", + " compile_result = subprocess.run(compiler_cmd[2], check=True, text=True, capture_output=True)\n", " run_cmd = [\"./optimized\"]\n", " run_result = subprocess.run(run_cmd, check=True, text=True, capture_output=True)\n", " return run_result.stdout\n", @@ -641,6 +745,22 @@ " yield stream_so_far " ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "4ba311ec-c16a-4fe0-946b-4b940704cf65", + "metadata": {}, + "outputs": [], + "source": [ + "def select_sample_program(sample_program):\n", + " if sample_program==\"pi\":\n", + " return pi\n", + " elif sample_program==\"python_hard\":\n", + " return python_hard\n", + " else:\n", + " return \"Type your Python program here\"" + ] + }, { "cell_type": "code", "execution_count": null, @@ -648,13 +768,20 @@ "metadata": {}, "outputs": [], "source": [ + "compiler_cmd = c_compiler_cmd(\"optimized\")\n", + "\n", "with gr.Blocks(css=css) as ui:\n", " gr.Markdown(\"## Convert code from Python to C++\")\n", " with gr.Row():\n", " python = gr.Textbox(label=\"Python code:\", value=python_hard, lines=10)\n", " cpp = gr.Textbox(label=\"C++ code:\", lines=10)\n", " with gr.Row():\n", - " model = gr.Dropdown([\"GPT\", \"Claude\", \"CodeQwen\"], label=\"Select model\", value=\"GPT\")\n", + " with gr.Column():\n", + " sample_program = gr.Radio([\"pi\", \"python_hard\"], label=\"Sample program\", value=\"python_hard\")\n", + " model = gr.Dropdown([\"GPT\", \"Claude\", \"CodeQwen\"], label=\"Select model\", value=\"GPT\")\n", + " with gr.Column():\n", + " architecture = gr.Radio([compiler_cmd[0]], label=\"Architecture\", interactive=False, value=compiler_cmd[0])\n", + " compiler = gr.Radio([compiler_cmd[1]], label=\"Compiler\", interactive=False, value=compiler_cmd[1])\n", " with gr.Row():\n", " convert = gr.Button(\"Convert code\")\n", " with gr.Row():\n", @@ -664,6 +791,7 @@ " python_out = gr.TextArea(label=\"Python result:\", elem_classes=[\"python\"])\n", " cpp_out = gr.TextArea(label=\"C++ result:\", elem_classes=[\"cpp\"])\n", "\n", + " sample_program.change(select_sample_program, inputs=[sample_program], outputs=[python])\n", " convert.click(optimize, inputs=[python, model], outputs=[cpp])\n", " python_run.click(execute_python, inputs=[python], outputs=[python_out])\n", " cpp_run.click(execute_cpp, inputs=[cpp], outputs=[cpp_out])\n", @@ -696,7 +824,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.11" + "version": "3.11.10" } }, "nbformat": 4, diff --git a/week4/optimized b/week4/optimized deleted file mode 100755 index c7745a1ecb8b3aca5de64ddae6d57a4b2d680165..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 36920 zcmeHQeQ;D&mOt;k1iCR3KL`on7&_nzL`L&PJ{%l6BrQY~s80Ja==jpbMCqK+;e~TYq#pJlr}t9T?+)lfo@hoenaiPPQ*%idjm}`-LR}+y&Gwc=&u_c#3Nz{fKj1Bj@5AsdOlk15*aOMi|%RroXZ7`v^G1gqyCB(C>h;fgfb7v922ahXBs?X zPZ`&xO;DTY1`zwx3p}~6*_O=sa=H%0`fbl*-PtFKl_CiQ1Ofs9 zfq+0jARrJB2nYlO0s;YnfIvVXAP^7;2m}NI0s(=5KtLcM5D*9m1Ox&C0fB%(Kp-Fx z5C{ka1Ofs9fq+0jARrJB2nYlO0s;YnfI#5?83L&%qyq!0+QrTfg%wCD@zB zQb#I9-Ki^S5N{kx{-{t--?)LYbBfY)R*`$oC{oY%N4+mh{_K%MeahsXpiG^gqs~$A ztH8S`dGMs1y?AyyT|N5|?+fptZoe`qf5)Sb9C~f zuRqhovLSGRwhVIrebfshHZXQE7 z%hKhAa;~+{`E-;M=6q;PHP%uU*3<&5t;+86P48~!HJMVR1847%pp&uAu-4wDj#jKe zUY~UANq=Q}(m!2FUQ;C{{mWtN49Z)e=QW5Ute56^2k~s?xx8)P?szLL>3@o-^C;F^ z5Ouh&i@bxb#~v6Ua&0()^?w`6QNK5@z&ptMVLoJ|&UN0wO7ua}{KLF{x62dXKRNi) z!SISVPIv2vPCq^Q_-WT8HCx<63tuQ6TC{=NEGf1Lq5u{dGk7CIq6s7 z7x&|aFK%*g$ai~p-`<{c&FxZdQNEjYvyU$LxSx`Kx0?p*gnYip6t% zJfHFpt*OHNEWq4Vc4NMbvjqKT8D|LEW?1!4!jGXfKgU@?9l+o@dU;+4-iR4xeD1J6 zXO{j8=2^noOC8)d0h>&eo9Aj)58h>&^Rvi1h%>Es!BvHt4Dv}Uil#@?0=oNtn`?i7q64P(LCzh+$b5YELvTIc-mSdPN}e%LxO z!&|W^ol2TzbN#HAT^l~i_747Pf_L|k=e@h9ji*9Mrof31b@XBWdx!nzb%nBS!ymN8 zx{|Oid0h>#|IqD$?#T0)^X#O5mg1W5ggj}(w8!Yddg|;-pGFh=lpJFoj>9hAvvuN` z*^h_)sDmFak9T)B=0%d+`9Ff5=Wi?L@O@~_Z5W>q{DL`3)F-7n*Z_OqtTd_)ViJ{dwalkQzsy zElvma{cCroWLN(Wxa~W&Nxph=A2t3>v+lfr?&Z+4z5iSId!u7aM~&}dwl%Ko{vdqcnn}FovnJvWaJjkU zId`ES#+LnPrh!uKdoIejEgmzD-iv$Yb>N=yBHkMIUWGMH^0dPSKhDNau<@BT9_xOj z{!|;EYvZTe_#13|zKt)n@weFc@7VYSHvTpn@3--H+xX=+{s9|bZ{r(n{0bW%xACh@ zK9!Otd0o%RwCD{SaZk$3Zj?PZ&WNC!N;;A5c|*Y|^#LmM$)2AnlvI{k`V9Ie(KlW5 z==wRRzok+tot3demhR8^J6US>Y?P%PQWn_XNNMY3sZYXd*LUQ!4`tdX8fe34~iT6nGL^C>Cu<&}uED$Kq5UOoT&tGd}zzo2_FA#+%sdk+VF@ zl98odiFJC!i?^&LzySq!fcOnLCzkDr>+pMUetUaA@@*AFYmsN&LbMTi+qa26M9yz_ zGiU;p5Oxr{o+FX6S)sIMh-=d+eSJEOI|BZTbdu`ElXM0Pe?0tvFKK8S;70J%$eG8B z+N6onRY~k8LpI(Aqa5EOLpFMXjD2FruxI2jZR9vVjC_KX^ZRGEi@7oKZ&*3MW9D-B zV&vFUMt-%GbNm6;PqgwZE1zWL*;bxo<@`pN>+^eW&Zk;AzlUa-=Z15BH;j}te#MVK zKp-Fx5C{ka1Ofs9fq+0jARrJB2nYlO0s;YnfIvVXAP^7;2m}NI0s(=5KtLcM5D*9m z1Ox&C0fB%(Kp-Fx5C{ka1Ofs9fq+0jARrJB2nYlO0s;YnfIvVXAP^7;2m}NI0s(=5 zKtLcM5D*9m1pW^q;DJvZkYOJv7i7i)0E1+{|2KK_t-X!+A{v0#l=+w2$p|1IO$V(4 z?Ev+Gu8~MWgaPR^2!X()6Cl4r62d}AAA>T}NLmj1YtR6wAf1N%2ww0g@*dDXf!_z> zfCkgYkyH&@1$t&2$v*+T13y&tF7rRO_iKsP77g<9C5vnIVpT0Hjl@F1h*r^>(A36Y zNYj1(CA9@=QMkcpuT~z8B~-+B&`O&$9Zh_z4Q;JnSQv>lA?kw`kH_LwMZRT=L&KV) zh!$!ccQCuIlk%SWnc1d_G_Cs#e`MZ13wg zo7)&^O*H=*{go!Ps2*>xD)jkli&bkJU%y|g`JXk^NW$0fCwGWOZMH@wp&0P870eCk z?W;6EIWnErq=%a0v1qKY2>-`?u%TTIVMbRLM`I6-!pvG4j^T`~gkk`b&~&VdhWfCs z2BQrsqJbpB4O(1{YdU%uZEmFD+)zXd#(gW;(OSJi*WxYVXi(RTB^9W_ni{ooxLV-u ziD=hR$%WJmbL`j z)PxmW1x!o0Jsc)?QIXE!SJaDYGmVfV@^YHkf_-GfU(wWN%$XLa#R~PtU|6N4Ex~Y< zn$Xz}`FCj_Dp?uJu0Jk!nqf-d#?Qg!N=Zs0W(uD}E*xAecUrQ?k~yXd>z7*cDNEKZ znPaW6{6qfnCWVfk(lasx}S)M(1AGSVje zLKu->b;$2J;sc z9rBkBISbg^`_FgCMGm>bA=f(OMu+^6L*C?&yBu<_DZ@)M{nR1z%yWz!j*r8!aX20h z$HL(_IQ(6n0^-;=9Oot%G!5hd<$ z!|U^6eN9LC4A5A8-U$70zaAVq%P(^@X#cSGd$1N&QRl}%izb-E*Z`BIR3JMBJjVl>$ zXu)U`E-R6UI&xp)(_x8up}VY+OI^#W3T-`oRf%W3s6X1JeHv!B{>75~_wkqf8~-5b4Ie*+a3*(29od`zP!j{i8hEat0eVO5oN z5mohIeMBp`prq)6lDQX@lwD9#j*kS=`HwU9;7g5gn*6yoQWnbiYyLRNxTML(ou?j} zdo4Xe(LKA(BO^rK*Gg_PgdGgVaG7oiKdd#-1N57jcV^9ccg2=hzc};X_uYP<@{9N1 z+8%xH+4-+F9vpbH>$P<|cHSHN#mUA!X&)Upuu@)nZ+dF&uC)(8^&f9;SoHLqS1zZ| znR#rPXU3+)^2hWuAAC=KaOZvhbE{tWJO4eIcl|p5@m&k|{liBaKfg8j=4%s!3m?sW z>+IP;_PNC7&ks(1_k~z6FZb7%v;UXsU(Cz+chQ1SW)~z OPJU|7)?lEA=zjq=>Kq~f From 2d93460791a94e835ba4446b0518cd4c7ba2c51e Mon Sep 17 00:00:00 2001 From: Kevin Bogusch Date: Mon, 23 Dec 2024 08:46:09 -0500 Subject: [PATCH 2/8] Disable run button if no c compiler --- week4/day4.ipynb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/week4/day4.ipynb b/week4/day4.ipynb index f140b92..12a9abe 100644 --- a/week4/day4.ipynb +++ b/week4/day4.ipynb @@ -519,7 +519,7 @@ " my_compiler = [\"Windows\", \"GCC\", [\"cmd\", \"/c\", \"gcc\", f\"{filename_base}.cpp\"]]\n", "\n", " if not my_compiler:\n", - " my_compiler=[my_platform, \"Unknown\", []]\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", " \n", " elif my_platform == \"Linux\":\n", " if os.path.isfile(\"./simple\"):\n", @@ -538,7 +538,7 @@ " my_compiler = [\"Linux\", \"CLang\", [\"clang\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", " \n", " if not my_compiler:\n", - " my_compiler=[my_platform, \"Unknown\", []]\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", "\n", " elif my_platform == \"Darwin\":\n", " if os.path.isfile(\"./simple\"):\n", @@ -549,12 +549,12 @@ " my_compiler = [\"Linux\", \"CLang\", [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", f\"{filename_base}\", f\"{filename_base}.cpp\"]]\n", "\n", " if not my_compiler:\n", - " my_compiler=[my_platform, \"Unknown\", []]\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", "\n", " if my_compiler:\n", " return my_compiler\n", " else:\n", - " return [\"Unknown\", \"Unknown\", []]\n" + " return [\"Unknown\", \"Unavailable\", []]\n" ] }, { @@ -576,14 +576,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 107, "id": "77f3ab5d-fcfb-4d3f-8728-9cacbf833ea6", "metadata": {}, "outputs": [], "source": [ "def execute_cpp(code):\n", " write_output(code)\n", - " print(f\"DEBUG. execute_cpp. compiler_cmd[2]=\\\"{compiler_cmd[2]}\\\"\")\n", " try:\n", " compile_result = subprocess.run(compiler_cmd[2], check=True, text=True, capture_output=True)\n", " run_cmd = [\"./optimized\"]\n", @@ -786,7 +785,10 @@ " convert = gr.Button(\"Convert code\")\n", " with gr.Row():\n", " python_run = gr.Button(\"Run Python\")\n", - " cpp_run = gr.Button(\"Run C++\")\n", + " if not compiler_cmd[1] == \"Unavailable\":\n", + " cpp_run = gr.Button(\"Run C++\")\n", + " else:\n", + " cpp_run = gr.Button(\"No compiler to run C++\", interactive=False)\n", " with gr.Row():\n", " python_out = gr.TextArea(label=\"Python result:\", elem_classes=[\"python\"])\n", " cpp_out = gr.TextArea(label=\"C++ result:\", elem_classes=[\"cpp\"])\n", From bc8229947d485e370f56d4470ad92ed4b553b164 Mon Sep 17 00:00:00 2001 From: Kevin Bogusch Date: Mon, 23 Dec 2024 09:18:24 -0500 Subject: [PATCH 3/8] Added more exception handling in c_compiler_cmd If there is any error, even writing the simple.cpp file, catch it and just return a "I don't know" diagnosis --- week4/day4.ipynb | 112 +++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/week4/day4.ipynb b/week4/day4.ipynb index 12a9abe..5ce0218 100644 --- a/week4/day4.ipynb +++ b/week4/day4.ipynb @@ -455,7 +455,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 111, "id": "e42286bc-085c-45dc-b101-234308e58269", "metadata": {}, "outputs": [], @@ -482,75 +482,75 @@ " return \"\"\n", "\n", "def c_compiler_cmd(filename_base):\n", - "\n", - " with open(\"simple.cpp\", \"w\") as f:\n", - " f.write(simple_cpp)\n", - "\n", - " \n", " my_platform = platform.system()\n", " my_compiler = []\n", + "\n", + " try:\n", + " with open(\"simple.cpp\", \"w\") as f:\n", + " f.write(simple_cpp)\n", + " \n", + " if my_platform == \"Windows\":\n", + " if os.path.isfile(VISUAL_STUDIO_2022_TOOLS):\n", + " if os.path.isfile(\"./simple.exe\"):\n", + " os.remove(\"./simple.exe\")\n", + " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Windows\", \"Visual Studio 2022\", [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", + " \n", + " if not my_compiler:\n", + " if os.path.isfile(VISUAL_STUDIO_2019_TOOLS):\n", + " if os.path.isfile(\"./simple.exe\"):\n", + " os.remove(\"./simple.exe\")\n", + " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Windows\", \"Visual Studio 2019\", [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", " \n", - " \n", - " if my_platform == \"Windows\":\n", - " if os.path.isfile(VISUAL_STUDIO_2022_TOOLS):\n", - " if os.path.isfile(\"./simple.exe\"):\n", - " os.remove(\"./simple.exe\")\n", - " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", - " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Windows\", \"Visual Studio 2022\", [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", - " \n", - " if not my_compiler:\n", - " if os.path.isfile(VISUAL_STUDIO_2019_TOOLS):\n", + " if not my_compiler:\n", " if os.path.isfile(\"./simple.exe\"):\n", " os.remove(\"./simple.exe\")\n", - " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", + " compile_cmd = [\"cmd\", \"/c\", \"gcc\", \"simple.cpp\"]\n", " if run_cmd(compile_cmd):\n", + " print(\"here\")\n", " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Windows\", \"Visual Studio 2019\", [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", - "\n", - " if not my_compiler:\n", - " if os.path.isfile(\"./simple.exe\"):\n", - " os.remove(\"./simple.exe\")\n", - " compile_cmd = [\"cmd\", \"/c\", \"gcc\", \"simple.cpp\"]\n", + " my_compiler = [\"Windows\", \"GCC\", [\"cmd\", \"/c\", \"gcc\", f\"{filename_base}.cpp\"]]\n", + " \n", + " if not my_compiler:\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", + " \n", + " elif my_platform == \"Linux\":\n", + " if os.path.isfile(\"./simple\"):\n", + " os.remove(\"./simple\")\n", + " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", " if run_cmd(compile_cmd):\n", - " print(\"here\")\n", " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Windows\", \"GCC\", [\"cmd\", \"/c\", \"gcc\", f\"{filename_base}.cpp\"]]\n", - "\n", - " if not my_compiler:\n", - " my_compiler=[my_platform, \"Unavailable\", []]\n", - " \n", - " elif my_platform == \"Linux\":\n", - " if os.path.isfile(\"./simple\"):\n", - " os.remove(\"./simple\")\n", - " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", - " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Linux\", \"GCC\", [\"gcc\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", - "\n", - " if not my_compiler:\n", + " my_compiler = [\"Linux\", \"GCC\", [\"gcc\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", + " \n", + " if not my_compiler:\n", + " if os.path.isfile(\"./simple\"):\n", + " os.remove(\"./simple\")\n", + " compile_cmd = [\"clang\", \"simple.cpp\", \"-o\", \"simple\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Linux\", \"CLang\", [\"clang\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", + " \n", + " if not my_compiler:\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", + " \n", + " elif my_platform == \"Darwin\":\n", " if os.path.isfile(\"./simple\"):\n", " os.remove(\"./simple\")\n", - " compile_cmd = [\"clang\", \"simple.cpp\", \"-o\", \"simple\"]\n", + " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", " if run_cmd(compile_cmd):\n", " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Linux\", \"CLang\", [\"clang\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", + " my_compiler = [\"Linux\", \"CLang\", [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", f\"{filename_base}\", f\"{filename_base}.cpp\"]]\n", " \n", - " if not my_compiler:\n", - " my_compiler=[my_platform, \"Unavailable\", []]\n", - "\n", - " elif my_platform == \"Darwin\":\n", - " if os.path.isfile(\"./simple\"):\n", - " os.remove(\"./simple\")\n", - " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", - " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Linux\", \"CLang\", [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", f\"{filename_base}\", f\"{filename_base}.cpp\"]]\n", - "\n", - " if not my_compiler:\n", - " my_compiler=[my_platform, \"Unavailable\", []]\n", - "\n", + " if not my_compiler:\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", + " except:\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", + " \n", " if my_compiler:\n", " return my_compiler\n", " else:\n", From ef351da849010b7695a46168701939299f62a65d Mon Sep 17 00:00:00 2001 From: Kevin Bogusch Date: Tue, 24 Dec 2024 08:39:29 -0500 Subject: [PATCH 4/8] Remove gcc from Windows --- week4/day4.ipynb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/week4/day4.ipynb b/week4/day4.ipynb index 5ce0218..26d16f9 100644 --- a/week4/day4.ipynb +++ b/week4/day4.ipynb @@ -508,15 +508,6 @@ " my_compiler = [\"Windows\", \"Visual Studio 2019\", [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", " \n", " if not my_compiler:\n", - " if os.path.isfile(\"./simple.exe\"):\n", - " os.remove(\"./simple.exe\")\n", - " compile_cmd = [\"cmd\", \"/c\", \"gcc\", \"simple.cpp\"]\n", - " if run_cmd(compile_cmd):\n", - " print(\"here\")\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Windows\", \"GCC\", [\"cmd\", \"/c\", \"gcc\", f\"{filename_base}.cpp\"]]\n", - " \n", - " if not my_compiler:\n", " my_compiler=[my_platform, \"Unavailable\", []]\n", " \n", " elif my_platform == \"Linux\":\n", From e360270530d9c3dc1388d7e6aa902400d767c7a5 Mon Sep 17 00:00:00 2001 From: Kevin Bogusch Date: Tue, 24 Dec 2024 09:39:59 -0500 Subject: [PATCH 5/8] Fixed g++ compilation command --- week4/day4.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/week4/day4.ipynb b/week4/day4.ipynb index 26d16f9..552d0c4 100644 --- a/week4/day4.ipynb +++ b/week4/day4.ipynb @@ -513,10 +513,10 @@ " elif my_platform == \"Linux\":\n", " if os.path.isfile(\"./simple\"):\n", " os.remove(\"./simple\")\n", - " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", + " compile_cmd = [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]\n", " if run_cmd(compile_cmd):\n", " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Linux\", \"GCC\", [\"gcc\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", + " my_compiler = [\"Linux\", \"GCC\", [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]]\n", " \n", " if not my_compiler:\n", " if os.path.isfile(\"./simple\"):\n", From 5a44ed71e0cc9a5abd876f244b8503086991fc3d Mon Sep 17 00:00:00 2001 From: Kevin Bogusch Date: Tue, 24 Dec 2024 10:01:27 -0500 Subject: [PATCH 6/8] Fixed run_cmd to account for empty stdout On Linux, a successful compile does not produce any standard out, which is what I was implicitly expecting. I added a dummy value for stdout if the command is successful, which ensures that even when the compiler produces no output, we still look like a success. --- week4/day4.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/week4/day4.ipynb b/week4/day4.ipynb index 552d0c4..32f4ffb 100644 --- a/week4/day4.ipynb +++ b/week4/day4.ipynb @@ -455,7 +455,7 @@ }, { "cell_type": "code", - "execution_count": 111, + "execution_count": 113, "id": "e42286bc-085c-45dc-b101-234308e58269", "metadata": {}, "outputs": [], @@ -477,7 +477,7 @@ "def run_cmd(command_to_run):\n", " try:\n", " run_result = subprocess.run(command_to_run, check=True, text=True, capture_output=True)\n", - " return run_result.stdout\n", + " return run_result.stdout if run_result.stdout else \"SUCCESS\"\n", " except:\n", " return \"\"\n", "\n", @@ -513,7 +513,7 @@ " elif my_platform == \"Linux\":\n", " if os.path.isfile(\"./simple\"):\n", " os.remove(\"./simple\")\n", - " compile_cmd = [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]\n", + " compile_cmd = [\"g++\", \"simple.cpp\", \"-o\", \"simple\"]\n", " if run_cmd(compile_cmd):\n", " if run_cmd([\"./simple\"]) == \"Hello\":\n", " my_compiler = [\"Linux\", \"GCC\", [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]]\n", From c20bdc46f34fe80649f841a77833ae2ad45a16d7 Mon Sep 17 00:00:00 2001 From: Kevin Bogusch Date: Tue, 24 Dec 2024 10:19:33 -0500 Subject: [PATCH 7/8] Added clang compilation syntax --- week4/day4.ipynb | 190 +++++++++++++++++++++++------------------------ 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/week4/day4.ipynb b/week4/day4.ipynb index 32f4ffb..e8c0419 100644 --- a/week4/day4.ipynb +++ b/week4/day4.ipynb @@ -453,101 +453,6 @@ "ui.launch(inbrowser=True)" ] }, - { - "cell_type": "code", - "execution_count": 113, - "id": "e42286bc-085c-45dc-b101-234308e58269", - "metadata": {}, - "outputs": [], - "source": [ - "import platform\n", - "\n", - "VISUAL_STUDIO_2022_TOOLS = \"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Community\\\\Common7\\Tools\\\\VsDevCmd.bat\"\n", - "VISUAL_STUDIO_2019_TOOLS = \"C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\2019\\\\BuildTools\\\\Common7\\\\Tools\\\\VsDevCmd.bat\"\n", - "\n", - "simple_cpp = \"\"\"\n", - "#include \n", - "\n", - "int main() {\n", - " std::cout << \"Hello\";\n", - " return 0;\n", - "}\n", - "\"\"\"\n", - "\n", - "def run_cmd(command_to_run):\n", - " try:\n", - " run_result = subprocess.run(command_to_run, check=True, text=True, capture_output=True)\n", - " return run_result.stdout if run_result.stdout else \"SUCCESS\"\n", - " except:\n", - " return \"\"\n", - "\n", - "def c_compiler_cmd(filename_base):\n", - " my_platform = platform.system()\n", - " my_compiler = []\n", - "\n", - " try:\n", - " with open(\"simple.cpp\", \"w\") as f:\n", - " f.write(simple_cpp)\n", - " \n", - " if my_platform == \"Windows\":\n", - " if os.path.isfile(VISUAL_STUDIO_2022_TOOLS):\n", - " if os.path.isfile(\"./simple.exe\"):\n", - " os.remove(\"./simple.exe\")\n", - " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", - " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Windows\", \"Visual Studio 2022\", [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", - " \n", - " if not my_compiler:\n", - " if os.path.isfile(VISUAL_STUDIO_2019_TOOLS):\n", - " if os.path.isfile(\"./simple.exe\"):\n", - " os.remove(\"./simple.exe\")\n", - " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", - " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Windows\", \"Visual Studio 2019\", [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", - " \n", - " if not my_compiler:\n", - " my_compiler=[my_platform, \"Unavailable\", []]\n", - " \n", - " elif my_platform == \"Linux\":\n", - " if os.path.isfile(\"./simple\"):\n", - " os.remove(\"./simple\")\n", - " compile_cmd = [\"g++\", \"simple.cpp\", \"-o\", \"simple\"]\n", - " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Linux\", \"GCC\", [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]]\n", - " \n", - " if not my_compiler:\n", - " if os.path.isfile(\"./simple\"):\n", - " os.remove(\"./simple\")\n", - " compile_cmd = [\"clang\", \"simple.cpp\", \"-o\", \"simple\"]\n", - " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Linux\", \"CLang\", [\"clang\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", - " \n", - " if not my_compiler:\n", - " my_compiler=[my_platform, \"Unavailable\", []]\n", - " \n", - " elif my_platform == \"Darwin\":\n", - " if os.path.isfile(\"./simple\"):\n", - " os.remove(\"./simple\")\n", - " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", - " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Linux\", \"CLang\", [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", f\"{filename_base}\", f\"{filename_base}.cpp\"]]\n", - " \n", - " if not my_compiler:\n", - " my_compiler=[my_platform, \"Unavailable\", []]\n", - " except:\n", - " my_compiler=[my_platform, \"Unavailable\", []]\n", - " \n", - " if my_compiler:\n", - " return my_compiler\n", - " else:\n", - " return [\"Unknown\", \"Unavailable\", []]\n" - ] - }, { "cell_type": "code", "execution_count": null, @@ -751,6 +656,101 @@ " return \"Type your Python program here\"" ] }, + { + "cell_type": "code", + "execution_count": 113, + "id": "e42286bc-085c-45dc-b101-234308e58269", + "metadata": {}, + "outputs": [], + "source": [ + "import platform\n", + "\n", + "VISUAL_STUDIO_2022_TOOLS = \"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Community\\\\Common7\\Tools\\\\VsDevCmd.bat\"\n", + "VISUAL_STUDIO_2019_TOOLS = \"C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\2019\\\\BuildTools\\\\Common7\\\\Tools\\\\VsDevCmd.bat\"\n", + "\n", + "simple_cpp = \"\"\"\n", + "#include \n", + "\n", + "int main() {\n", + " std::cout << \"Hello\";\n", + " return 0;\n", + "}\n", + "\"\"\"\n", + "\n", + "def run_cmd(command_to_run):\n", + " try:\n", + " run_result = subprocess.run(command_to_run, check=True, text=True, capture_output=True)\n", + " return run_result.stdout if run_result.stdout else \"SUCCESS\"\n", + " except:\n", + " return \"\"\n", + "\n", + "def c_compiler_cmd(filename_base):\n", + " my_platform = platform.system()\n", + " my_compiler = []\n", + "\n", + " try:\n", + " with open(\"simple.cpp\", \"w\") as f:\n", + " f.write(simple_cpp)\n", + " \n", + " if my_platform == \"Windows\":\n", + " if os.path.isfile(VISUAL_STUDIO_2022_TOOLS):\n", + " if os.path.isfile(\"./simple.exe\"):\n", + " os.remove(\"./simple.exe\")\n", + " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Windows\", \"Visual Studio 2022\", [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", + " \n", + " if not my_compiler:\n", + " if os.path.isfile(VISUAL_STUDIO_2019_TOOLS):\n", + " if os.path.isfile(\"./simple.exe\"):\n", + " os.remove(\"./simple.exe\")\n", + " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Windows\", \"Visual Studio 2019\", [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", + " \n", + " if not my_compiler:\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", + " \n", + " elif my_platform == \"Linux\":\n", + " if os.path.isfile(\"./simple\"):\n", + " os.remove(\"./simple\")\n", + " compile_cmd = [\"g++\", \"simple.cpp\", \"-o\", \"simple\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Linux\", \"GCC (g++)\", [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]]\n", + " \n", + " if not my_compiler:\n", + " if os.path.isfile(\"./simple\"):\n", + " os.remove(\"./simple\")\n", + " compile_cmd = [\"clang++\", \"simple.cpp\", \"-o\", \"simple\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Linux\", \"CLang (Clang++)\", [\"clang++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", + " \n", + " if not my_compiler:\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", + " \n", + " elif my_platform == \"Darwin\":\n", + " if os.path.isfile(\"./simple\"):\n", + " os.remove(\"./simple\")\n", + " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", + " if run_cmd(compile_cmd):\n", + " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " my_compiler = [\"Linux\", \"CLang\", [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", f\"{filename_base}\", f\"{filename_base}.cpp\"]]\n", + " \n", + " if not my_compiler:\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", + " except:\n", + " my_compiler=[my_platform, \"Unavailable\", []]\n", + " \n", + " if my_compiler:\n", + " return my_compiler\n", + " else:\n", + " return [\"Unknown\", \"Unavailable\", []]\n" + ] + }, { "cell_type": "code", "execution_count": null, From e411df35256c02a5d9fba23baa8b2e6445124fe0 Mon Sep 17 00:00:00 2001 From: Kevin Bogusch Date: Tue, 24 Dec 2024 10:26:13 -0500 Subject: [PATCH 8/8] Fixed clang++ for Mac; updated labels --- week4/day4.ipynb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/week4/day4.ipynb b/week4/day4.ipynb index e8c0419..97730f1 100644 --- a/week4/day4.ipynb +++ b/week4/day4.ipynb @@ -658,7 +658,7 @@ }, { "cell_type": "code", - "execution_count": 113, + "execution_count": 115, "id": "e42286bc-085c-45dc-b101-234308e58269", "metadata": {}, "outputs": [], @@ -698,7 +698,7 @@ " os.remove(\"./simple.exe\")\n", " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " if run_cmd([\"./simple.exe\"]) == \"Hello\":\n", " my_compiler = [\"Windows\", \"Visual Studio 2022\", [\"cmd\", \"/c\", VISUAL_STUDIO_2022_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", " \n", " if not my_compiler:\n", @@ -707,7 +707,7 @@ " os.remove(\"./simple.exe\")\n", " compile_cmd = [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", \"simple.cpp\"]\n", " if run_cmd(compile_cmd):\n", - " if run_cmd([\"./simple\"]) == \"Hello\":\n", + " if run_cmd([\"./simple.exe\"]) == \"Hello\":\n", " my_compiler = [\"Windows\", \"Visual Studio 2019\", [\"cmd\", \"/c\", VISUAL_STUDIO_2019_TOOLS, \"&\", \"cl\", f\"{filename_base}.cpp\"]]\n", " \n", " if not my_compiler:\n", @@ -727,7 +727,7 @@ " compile_cmd = [\"clang++\", \"simple.cpp\", \"-o\", \"simple\"]\n", " if run_cmd(compile_cmd):\n", " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Linux\", \"CLang (Clang++)\", [\"clang++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", + " my_compiler = [\"Linux\", \"Clang++\", [\"clang++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", " \n", " if not my_compiler:\n", " my_compiler=[my_platform, \"Unavailable\", []]\n", @@ -735,10 +735,10 @@ " elif my_platform == \"Darwin\":\n", " if os.path.isfile(\"./simple\"):\n", " os.remove(\"./simple\")\n", - " compile_cmd = [\"gcc\", \"simple.cpp\"]\n", + " compile_cmd = [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", \"simple\", \"simple.cpp\"]\n", " if run_cmd(compile_cmd):\n", " if run_cmd([\"./simple\"]) == \"Hello\":\n", - " my_compiler = [\"Linux\", \"CLang\", [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", f\"{filename_base}\", f\"{filename_base}.cpp\"]]\n", + " my_compiler = [\"Linux\", \"Clang++\", [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", f\"{filename_base}\", f\"{filename_base}.cpp\"]]\n", " \n", " if not my_compiler:\n", " my_compiler=[my_platform, \"Unavailable\", []]\n",