From 3d054bfa6ce74a11107b8b276426bcc498cadd56 Mon Sep 17 00:00:00 2001 From: Iblis Lin Date: Wed, 26 Sep 2018 10:33:03 +0800 Subject: hipe_llvm_main: fix tmpfs dir on FreeBSD Upstream this patch from FreeBSD Ports: https://svnweb.freebsd.org/ports/head/lang/erlang-runtime21/files/patch-lib_hipe_llvm_hipe__llvm__main.erl?revision=473434&view=markup --- .gitignore | 1 + lib/hipe/llvm/hipe_llvm_main.erl | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fee8cba0c7..59c80358f1 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ i686-pc-linux-gnu x86_64-unknown-linux-gnu i386-apple-darwin[0-9]*.[0-9]*.[0-9]* x86_64-apple-darwin[0-9]*.[0-9]*.[0-9]* +x86_64-unknown-freebsd[0-9]*.[0-9]* sparc-sun-solaris[0-9]*.[0-9]* i386-pc-solaris[0-9]*.[0-9]* i386-unknown-freebsd[0-9]*.[0-9]* diff --git a/lib/hipe/llvm/hipe_llvm_main.erl b/lib/hipe/llvm/hipe_llvm_main.erl index 54c435c127..1d7a51b5b1 100644 --- a/lib/hipe/llvm/hipe_llvm_main.erl +++ b/lib/hipe/llvm/hipe_llvm_main.erl @@ -527,7 +527,7 @@ unique_folder(FunName, Arity, Options) -> true -> %% Store folder in current directory DirName; false -> %% Temporarily store folder in tempfs (/dev/shm/) - "/dev/shm/" ++ DirName + tmpfs_folder() ++ DirName end, %% Make sure it does not exist case dir_exists(Dir) of @@ -537,6 +537,14 @@ unique_folder(FunName, Arity, Options) -> Dir end. +tmpfs_folder() -> + case os:type() of + {unix, linux} -> + "/dev/shm/"; + {unix, _} -> %% Fallback to tmp dir. e.g. FreeBSD + "/tmp/" + end. + %% @doc Function that checks that a given Filename is an existing Directory %% Name (from http://rosettacode.org/wiki/Ensure_that_a_file_exists#Erlang) dir_exists(Filename) -> -- cgit v1.2.3 From d0ee664621f485b533a26805c21c8058ad59a6b7 Mon Sep 17 00:00:00 2001 From: Iblis Lin Date: Thu, 27 Sep 2018 09:24:53 +0800 Subject: update comment --- lib/hipe/llvm/hipe_llvm_main.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hipe/llvm/hipe_llvm_main.erl b/lib/hipe/llvm/hipe_llvm_main.erl index 1d7a51b5b1..44f0566379 100644 --- a/lib/hipe/llvm/hipe_llvm_main.erl +++ b/lib/hipe/llvm/hipe_llvm_main.erl @@ -526,7 +526,7 @@ unique_folder(FunName, Arity, Options) -> case proplists:get_bool(llvm_save_temps, Options) of true -> %% Store folder in current directory DirName; - false -> %% Temporarily store folder in tempfs (/dev/shm/) + false -> %% Temporarily store folder in tempfs or tmp dir tmpfs_folder() ++ DirName end, %% Make sure it does not exist -- cgit v1.2.3