View Issue Details

IDProjectCategoryView StatusLast Update
0003301OpenFOAMBugpublic2020-01-07 11:28
Reporterpaulmedwards Assigned Tohenry  
PrioritynormalSeveritytrivialReproducibilityalways
Status resolvedResolutionreopened 
Product Versiondev 
Summary0003301: Issue compiling in a path containing a symlink
DescriptionThe `/etc/bashrc` will take the physical path for `FOAM_INST_DIR` here: https://github.com/OpenFOAM/OpenFOAM-dev/blob/master/etc/bashrc#L46. This is then used for other environment variables, e.g. WM_PROJECT_INST_DIR and WM_PROJECT_DIR.

In the wmake command it compares the current working directory with `WM_PROJECT_DIR` here: https://github.com/edwardsp/OpenFOAM-dev/blob/master/wmake/wmake#L398. Since just `$PWD`is used this will not match if there are symlinks in the path.

A possible solution is to change directory to `pwd -P`.
TagsNo tags attached.

Relationships

related to 0003303 resolvedhenry Compilation of (Intel) MPI fails 

Activities

henry

2019-07-02 08:58

manager   ~0010538

It is not clear how to reproduce this problem, we compile OpenFOAM on many systems with different compilers and operating systems and have not had any such problems.
Are you sure your proposed change will work on all systems? How much testing have you performed?

henry

2019-07-02 09:02

manager   ~0010539

In wclean we have

    expandPath "$PWD"
    if [ "$exPath" = "$WM_PROJECT_DIR" ]

because apparently `pwd -P` does not resolve all potential problems:

expandPath()
{
    if [ -d "$1" ]
    then
        exPath=$(cd "$1" && pwd -P)
    else
        exPath=$(cd $(dirname "$1") && pwd -P)
    fi
}

we could use this in wmake also.

paulmedwards

2019-07-02 09:44

reporter   ~0010541

I haven't done extensive testing here. I have created a script to automate building OpenFOAM and the fix I have is to just switch to the physical path before sourcing bashrc and building: `cd $(readlink -f $BUILD_DIR)`. It was a problem for me as my cluster setup had a frontend as the NFS server. The cluster nodes mount in a different place to where the device is mounted and so symlinks are created on the frontend to keep consistent paths.

If WM_INST_DIR is set explicitly to the path with symlinks I would expect it to work (i.e. bashrc#L46 was changed to `export FOAM_INST_DIR=/path/with/symlink`). It is the detection that takes the physical path but wmake just uses the path as it is. TBH I think, if a change were to be made, it would be better to remove the `pwd -P` from the detection in bashrc#L46.

This is how I build and I've added some commands to create a symlink to demonstrate the error:

8<---------------------------------------------------
BUILD_DIR=/scratch
INSTALL_DIR=/apps

# openfoam will get confused if the BUILD_DIR is a symlink
cd $(readlink -f $BUILD_DIR)

#
# this is the part that adds a symlink to show the error
#
mkdir foo
ln -s foo bar
cd bar

mkdir OpenFOAM
cd OpenFOAM
git clone git://github.com/OpenFOAM/OpenFOAM-6.git
git clone git://github.com/OpenFOAM/ThirdParty-6.git

export PATH=/usr/mpi/gcc/openmpi-4.0.2a1/bin:$PATH
source OpenFOAM-6/etc/bashrc

cd OpenFOAM-6
./Allwmake -j 2>&1 | tee build.log
--------------------------------------------------->8



This is the output:

8<---------------------------------------------------
...
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file PstreamGlobals.C
Making dependency list for source file UPstream.C
Making dependency list for source file UIPread.C
Making dependency list for source file UOPwrite.C
g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -DOMPI_SKIP_MPICXX -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/hwloc/hwloc201/hwloc/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include -pthread -IlnInclude -I. -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OpenFOAM/lnInclude -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OSspecific/POSIX/lnInclude -fPIC -c UOPwrite.C -o Make/linux64GccDPInt32OptSYSTEMOPENMPI/UOPwrite.o
g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -DOMPI_SKIP_MPICXX -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/hwloc/hwloc201/hwloc/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include -pthread -IlnInclude -I. -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OpenFOAM/lnInclude -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OSspecific/POSIX/lnInclude -fPIC -c UIPread.C -o Make/linux64GccDPInt32OptSYSTEMOPENMPI/UIPread.o
g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -DOMPI_SKIP_MPICXX -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/hwloc/hwloc201/hwloc/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include -pthread -IlnInclude -I. -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OpenFOAM/lnInclude -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OSspecific/POSIX/lnInclude -fPIC -c UPstream.C -o Make/linux64GccDPInt32OptSYSTEMOPENMPI/UPstream.o
g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -DOMPI_SKIP_MPICXX -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/hwloc/hwloc201/hwloc/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include -pthread -IlnInclude -I. -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OpenFOAM/lnInclude -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OSspecific/POSIX/lnInclude -fPIC -c PstreamGlobals.C -o Make/linux64GccDPInt32OptSYSTEMOPENMPI/PstreamGlobals.o
g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -DOMPI_SKIP_MPICXX -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/hwloc/hwloc201/hwloc/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent -I/usr/mpi/gcc/openmpi-4.0.2a1/include/openmpi/opal/mca/event/libevent2022/libevent/include -I/usr/mpi/gcc/openmpi-4.0.2a1/include -pthread -IlnInclude -I. -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OpenFOAM/lnInclude -I/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/src/OSspecific/POSIX/lnInclude -fPIC -shared -Xlinker --add-needed -Xlinker --no-as-needed Make/linux64GccDPInt32OptSYSTEMOPENMPI/UOPwrite.o Make/linux64GccDPInt32OptSYSTEMOPENMPI/UIPread.o Make/linux64GccDPInt32OptSYSTEMOPENMPI/UPstream.o Make/linux64GccDPInt32OptSYSTEMOPENMPI/PstreamGlobals.o -L/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt32OptSYSTEMOPENMPI/lib \
    -pthread -Wl,-rpath -Wl,/usr/mpi/gcc/openmpi-4.0.2a1/lib64 -Wl,--enable-new-dtags -L/usr/mpi/gcc/openmpi-4.0.2a1/lib64 -lmpi -o /mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt32Opt/lib/openmpi-system/libPstream.so
touch: cannot touch ‘/mnt/resource/scratch/foo/OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt32OptSYSTEMOPENMPI/src/Pstream/mpi/using:openmpi-system’: No such file or directory
--------------------------------------------------->8

henry

2019-07-02 09:52

manager   ~0010543

> I think, if a change were to be made, it would be better to remove the `pwd -P` from the detection in bashrc#L46.

This line has been changed over and over again and there is always some unusual installation configuration for which it causes problem. If we change it we would expect that many users installations would no longer compile and/or run.

Does using

    expandPath "$PWD"
    if [ "$exPath" = "$WM_PROJECT_DIR" ]

in wmake help? At least this change would be consistent with wclean.

paulmedwards

2019-07-02 10:29

reporter   ~0010545

This works for me:

8<----------------------------------------------------------
diff --git a/wmake/wmake b/wmake/wmake
index 4836880..83abfab 100755
--- a/wmake/wmake
+++ b/wmake/wmake
@@ -395,10 +395,11 @@ fi
 #------------------------------------------------------------------------------
 
 objectsDir=$MakeDir/$WM_OPTIONS
-if [[ "$PWD" = *"$WM_PROJECT_DIR"* ]]
+expandPath "$PWD"
+if [[ "$exPath" = *"$WM_PROJECT_DIR"* ]]
 then
     platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}
- objectsDir=$platformPath${PWD//$WM_PROJECT_DIR/}
+ objectsDir=$platformPath${exPath//$WM_PROJECT_DIR/}
 fi
 
 (
---------------------------------------------------------->8

henry

2019-07-02 11:59

manager   ~0010547

Resolved by commit 9980357df166e81b5d67fe6de33f9fff7869e373

henry

2019-07-16 10:05

manager   ~0010572

See https://bugs.openfoam.org/view.php?id=3303

Issue History

Date Modified Username Field Change
2019-07-02 08:29 paulmedwards New Issue
2019-07-02 08:58 henry Note Added: 0010538
2019-07-02 09:02 henry Note Added: 0010539
2019-07-02 09:44 paulmedwards Note Added: 0010541
2019-07-02 09:52 henry Note Added: 0010543
2019-07-02 10:29 paulmedwards Note Added: 0010545
2019-07-02 11:59 henry Assigned To => henry
2019-07-02 11:59 henry Status new => resolved
2019-07-02 11:59 henry Resolution open => fixed
2019-07-02 11:59 henry Note Added: 0010547
2019-07-16 10:05 henry Status resolved => feedback
2019-07-16 10:05 henry Resolution fixed => reopened
2019-07-16 10:05 henry Note Added: 0010572
2019-07-16 10:05 henry Relationship added related to 0003303
2020-01-07 11:28 henry Status feedback => resolved