Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for macOS #592

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

add support for macOS #592

wants to merge 10 commits into from

Conversation

s-u
Copy link

@s-u s-u commented Sep 15, 2018

This is a minimal set of code changes and additions to cmake rules to allow flang and libpgmath to build on macOS (aka Darwin).

[Tested using clang6 to build on Darwin 15.6.0 (aka OS X 10.11.6)]

@gklimowicz
Copy link
Contributor

Simon, can you do an individual contributor license agreement for us so we can take this pull request?

NVIDIA is requiring that we do CLAs for this sort of outside contribution.

This is described in the Flang wiki here: https://github.com/flang-compiler/flang/wiki/Community

@gklimowicz
Copy link
Contributor

@s-u FYI, I can't take these changes without a completed contributor license agreement. At least for about another few weeks.

If you have an update for this, please let me know.

@kiranchandramohan
Copy link
Collaborator

@s-u CLA (contributor license agreement) is not a requirement now. If you are interested in submitting this PR please rebase, else consider closing.

@s-u
Copy link
Author

s-u commented Feb 15, 2021

@kiranchandramohan thanks, rebased and updated.
I have tested the build using classic-flang-llvm-project (bootstrapped with Xcode 10.3) on macOS 10.14 (Mojave) = Darwin 18.

@pawosm-arm
Copy link
Collaborator

Seems like each time I thought I was approving particular commit, it was approval for the entire PR!

Copy link
Collaborator

@pawosm-arm pawosm-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message user fileno() instead of direct structure access is about fileno() only, yet the commit additionally sorts out dumpregs()/getRegs() definitions. This is considered as lame behavior, consider splitting this commit in two, or update the commit message to reflect correctly the scope of the change.

@dnoan
Copy link

dnoan commented Mar 25, 2021

runtime/flangrti/CMakeLists.txt has FLANG_LIBOMP and LIBPGMATH hard-coded to libomp.so and libpgmath.so. These should be set to libomp.dylib and libpgmath.dylib on Mac. Otherwise the project doesn't compile.

@kiranchandramohan
Copy link
Collaborator

@s-u Can you address @dnoan's comment above?

Also could you let me know the build instructions you used for Mac?

@s-u
Copy link
Author

s-u commented Apr 11, 2021

Build instruction are like in the Wiki only slightly modified - your mileage may wary depending on tools used.

BASE="`pwd`"
CMAKE=/Applications/CMake.app/Contents/bin/cmake

INSTALL_PREFIX=/opt/flang
CMAKE_OPTIONS="-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
    -DLLVM_CONFIG=$INSTALL_PREFIX/bin/llvm-config \
    -DCMAKE_CXX_COMPILER=$INSTALL_PREFIX/bin/clang++ \
    -DCMAKE_C_COMPILER=$INSTALL_PREFIX/bin/clang \
    -DCMAKE_Fortran_COMPILER=$INSTALL_PREFIX/bin/flang 
    -DCMAKE_Fortran_COMPILER_ID=Flang \
    -DCMAKE_BUILD_TYPE=Release \
    -DLLVM_TARGETS_TO_BUILD=X86"

cd classic-flang-llvm-project
mkdir -p build && cd build
## There is a bug in that branch that uses wrong flags for xml2 so we have to disable it
$CMAKE $CMAKE_OPTIONS -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
       -DLLVM_ENABLE_CLASSIC_FLANG=ON -DLLVM_ENABLE_PROJECTS="clang;openmp;libcxx;libcxxabi" \
       -DLLVM_ENABLE_LIBXML2=OFF ../llvm
make -j12

cd "$BASE"

(cd flang/runtime/libpgmath
 mkdir -p build && cd build
 $CMAKE $CMAKE_OPTIONS ..
 make -j12
 make install)

(cd flang
 mkdir -p build && cd build
 $CMAKE $CMAKE_OPTIONS -DFLANG_LLVM_EXTENSIONS=ON \
	-DFLANG_LIBOMP=$INSTALL_PREFIX/lib/libomp.dylib -DLIBPGMATH=$INSTALL_PREFIX/lib/libpgmath.dylib ..
 make -j12
 make install)

@dnoan it says that those are undefined, so if you define them it works, no code change needed. I have now added a fix for the suffixes as well (so now you no longer need to set those).

@isuruf isuruf mentioned this pull request Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants