Skip to content

Commit

Permalink
FreeBSD fixes: change shebang line in shell scripts, detect FreeBSD a…
Browse files Browse the repository at this point in the history
…nd use clang instead of gcc to link
  • Loading branch information
Harris Snyder committed Dec 4, 2021
1 parent a2d76cf commit ca348c4
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bench.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Compile the latest master and a given MR in Release mode from scratch.
#
Expand Down
2 changes: 1 addition & 1 deletion build0.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion build1.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion ci/azure_install_macos.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/azure_mirror.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion ci/azure_status.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/create_source_tarball.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/create_source_tarball0.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/github_mirror.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion ci/grammar_conflicts.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion ci/upload_docs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion ci/upload_tarball.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion ci/version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This script extracts the project's current version from git using
# `git describe`, which determines the version based on the latest tag, such as:
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/interop/mod2.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/interop/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
13 changes: 11 additions & 2 deletions src/bin/lfortran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,15 @@ int compile_to_object_file_cpp(const std::string &infile,
out.open(outfile_empty);
out << " ";
}
std::string CC;
if (compiler_options.platform == LFortran::Platform::macOS_Intel
|| compiler_options.platform == LFortran::Platform::macOS_ARM
|| compiler_options.platform == LFortran::Platform::FreeBSD) {
CC = "clang";
} else {
CC = "gcc";
}
char *env_CC = std::getenv("LFORTRAN_CC");
std::string CC="gcc";
if (env_CC) CC = env_CC;
std::string cmd = CC + " -c " + outfile_empty + " -o " + outfile;
int err = system(cmd.c_str());
Expand Down Expand Up @@ -1053,7 +1060,8 @@ int link_executable(const std::vector<std::string> &infiles,
} else {
std::string CC;
if (compiler_options.platform == LFortran::Platform::macOS_Intel
|| compiler_options.platform == LFortran::Platform::macOS_ARM) {
|| compiler_options.platform == LFortran::Platform::macOS_ARM
|| compiler_options.platform == LFortran::Platform::FreeBSD) {
CC = "clang";
} else {
CC = "gcc";
Expand Down Expand Up @@ -1281,6 +1289,7 @@ int main(int argc, char *argv[])
case (LFortran::Platform::macOS_Intel) : std::cout << "macOS Intel"; break;
case (LFortran::Platform::macOS_ARM) : std::cout << "macOS ARM"; break;
case (LFortran::Platform::Windows) : std::cout << "Windows"; break;
case (LFortran::Platform::FreeBSD) : std::cout << "FreeBSD"; break;
}
std::cout << std::endl;
#ifdef HAVE_LFORTRAN_LLVM
Expand Down
4 changes: 4 additions & 0 deletions src/lfortran/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ Platform get_platform()
return Platform::macOS_Intel;
# endif
# else
# ifdef __FreeBSD__
return Platform::FreeBSD;
# else
return Platform::Linux;
# endif
# endif
#endif
}
Expand Down
3 changes: 2 additions & 1 deletion src/lfortran/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ enum Platform {
Linux,
macOS_Intel,
macOS_ARM,
Windows
Windows,
FreeBSD
};

Platform get_platform();
Expand Down
2 changes: 1 addition & 1 deletion test_lfortran_cmdline
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -x
Expand Down
2 changes: 1 addition & 1 deletion tests/interop/generate_mod_files.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down

0 comments on commit ca348c4

Please sign in to comment.