<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 10, 2021 at 9:34 AM Satish Balay <<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 10 Mar 2021, Fande Kong wrote:<br>
<br>
> Thanks, Barry,<br>
> <br>
> It seems PETSc works fine with manually built compilers. We are pretty much<br>
> sure that the issue is related to conda. Conda might introduce extra flags.<br>
> <br>
> We still need to make it work with conda because we deliver our package via<br>
> conda for users.<br>
> <br>
> <br>
> I unset all flags from conda, and got slightly different results this<br>
> time. The log was attached. Anyone could explain the motivation that we<br>
> try to build executable without a main function?<br>
<br>
Its attempting to build a shared library - which shouldn't have a main.<br>
<br>
However - the primary issue is:<br>
<br>
>>>>><br>
Executing: mpicc -o /var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-pkset22y/config.setCompilers/conftest /var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-pkset22y/config.setCompilers/conftest.o -L/var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-pkset22y/config.setCompilers -lconftest<br>
Possible ERROR while running linker: exit code 1<br>
stderr:<br>
ld: can't link with a main executable file '/var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-pkset22y/config.setCompilers/libconftest.dylib' for architecture x86_64<br>
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)<br>
<<<<br>
<br>
Here its built a .dylib - and attempting to use it. But the compiler gives the above error.<br>
<br>
Can you build with conda compilers - but outside conda env? It appears to have:<br></blockquote><div><br></div><div>I am already outside of conda (build), but in order to use conda compilers, we need a few variables. <br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
AS=/Users/kongf/miniconda3/envs/testpetsc/bin/x86_64-apple-darwin13.4.0-as<br>
AR=/Users/kongf/miniconda3/envs/testpetsc/bin/x86_64-apple-darwin13.4.0-ar<br>
CXX_FOR_BUILD=/Users/kongf/miniconda3/envs/testpetsc/bin/x86_64-apple-darwin13.4.0-clang++<br>
INSTALL_NAME_TOOL=/Users/kongf/miniconda3/envs/testpetsc/bin/x86_64-apple-darwin13.4.0-install_name_tool<br>
CC_FOR_BUILD=/Users/kongf/miniconda3/envs/testpetsc/bin/x86_64-apple-darwin13.4.0-clang<br>
FC_FOR_BUILD=/Users/kongf/miniconda3/envs/testpetsc/bin/-gfortran<br>
LD=/Users/kongf/miniconda3/envs/testpetsc/bin/x86_64-apple-darwin13.4.0-ld<br>
<br>
Don't know if any one of them is making a difference.<br></blockquote><div><br></div><div>I unset all these variables, and did not make a difference.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Also you might want to comment out "self.executeTest(self.resetEnvCompilers)" in setCompilers.py to see if its making a difference [same with self.checkEnvCompilers?<br></blockquote><div><br></div><div>Still the same issue. Might it is just a bad compiler <br><br><br></div><div>Thanks for your help<br><br></div><div>Fande,<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
Satish<br>
<br>
<br>
> <br>
> Thanks,<br>
> <br>
> Fande<br>
> <br>
> Executing: mpicc -c -o<br>
> /var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-pkset22y/config.setCompilers/conftest.o<br>
> -I/var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-pkset22y/config.setCompilers<br>
> -fPIC<br>
> /var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-pkset22y/config.setCompilers/conftest.c<br>
> <br>
> Successful compile:<br>
> Source:<br>
> #include "confdefs.h"<br>
> #include "conffix.h"<br>
> #include <stdio.h><br>
> int (*fprintf_ptr)(FILE*,const char*,...) = fprintf;<br>
> void foo(void){<br>
> fprintf_ptr(stdout,"hello");<br>
> return;<br>
> }<br>
> void bar(void){foo();}<br>
> Running Executable WITHOUT threads to time it out<br>
> Executing: mpicc -o<br>
> /var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-pkset22y/config.setCompilers/libconftest.so<br>
> -dynamic -fPIC<br>
> /var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-pkset22y/config.setCompilers/conftest.o<br>
> <br>
> Possible ERROR while running linker: exit code 1<br>
> stderr:<br>
> Undefined symbols for architecture x86_64:<br>
> "_main", referenced from:<br>
> implicit entry/start for main executable<br>
> ld: symbol(s) not found for architecture x86_64<br>
> clang-11: error: linker command failed with exit code 1 (use -v to see<br>
> invocation)<br>
> Rejected C compiler flag -fPIC because it was not compatible with<br>
> shared linker mpicc using flags ['-dynamic']<br>
> <br>
> <br>
> On Mon, Mar 8, 2021 at 7:28 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:<br>
> <br>
> ><br>
> > Fande,<br>
> ><br>
> > I see you are using CONDA, this can cause issues since it sticks all<br>
> > kinds of things into the environment. PETSc tries to remove some of them<br>
> > but perhaps not enough. If you run printenv you will see all the mess it is<br>
> > dumping in.<br>
> ><br>
> > Can you trying the same build without CONDA environment?<br>
> ><br>
> > Barry<br>
> ><br>
> ><br>
> > On Mar 8, 2021, at 7:31 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
> ><br>
> > On Mon, Mar 8, 2021 at 8:23 PM Fande Kong <<a href="mailto:fdkong.jd@gmail.com" target="_blank">fdkong.jd@gmail.com</a>> wrote:<br>
> ><br>
> >> Thanks Matthew,<br>
> >><br>
> >> Hmm, we still have the same issue after shutting off all unknown flags.<br>
> >><br>
> ><br>
> > Oh, I was misinterpreting the error message:<br>
> ><br>
> > ld: can't link with a main executable file<br>
> > '/var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-6v1w4q4u/config.setCompilers/libconftest.dylib'<br>
> ><br>
> > So clang did not _actually_ make a shared library, it made an executable.<br>
> > Did clang-11 change the options it uses to build a shared library?<br>
> ><br>
> > Satish, do we test with clang-11?<br>
> ><br>
> > Thanks,<br>
> ><br>
> > Matt<br>
> ><br>
> > Thanks,<br>
> >><br>
> >> Fande<br>
> >><br>
> >> On Mon, Mar 8, 2021 at 6:07 PM Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
> >><br>
> >>> On Mon, Mar 8, 2021 at 7:55 PM Fande Kong <<a href="mailto:fdkong.jd@gmail.com" target="_blank">fdkong.jd@gmail.com</a>> wrote:<br>
> >>><br>
> >>>> Hi All,<br>
> >>>><br>
> >>>> mpicc rejected "-fPIC". Anyone has a clue how to work around this issue?<br>
> >>>><br>
> >>><br>
> >>> The failure is at the last step<br>
> >>><br>
> >>> Executing: mpicc -o<br>
> >>> /var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-6v1w4q4u/config.setCompilers/conftest<br>
> >>> -fPIC<br>
> >>> /var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-6v1w4q4u/config.setCompilers/conftest.o<br>
> >>> -L/var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-6v1w4q4u/config.setCompilers<br>
> >>> -lconftest<br>
> >>> Possible ERROR while running linker: exit code 1<br>
> >>> stderr:<br>
> >>> ld: can't link with a main executable file<br>
> >>> '/var/folders/tv/ljnkj46x3nq45cp9tbkc000c0000gn/T/petsc-6v1w4q4u/config.setCompilers/libconftest.dylib'<br>
> >>> for architecture x86_64<br>
> >>> clang-11: error: linker command failed with exit code 1 (use -v to see<br>
> >>> invocation)<br>
> >>><br>
> >>> but you have some flags stuck in which may or may not affect this. I<br>
> >>> would try shutting them off:<br>
> >>><br>
> >>> LDFLAGS_LD=-pie -headerpad_max_install_names -dead_strip_dylibs -rpath<br>
> >>> /Users/kongf/miniconda3/envs/moose/lib<br>
> >>> -L/Users/kongf/miniconda3/envs/moose/lib<br>
> >>><br>
> >>> I cannot tell exactly why clang is failing because it does not report a<br>
> >>> specific error.<br>
> >>><br>
> >>> Thanks,<br>
> >>><br>
> >>> Matt<br>
> >>><br>
> >>> The log was attached.<br>
> >>>><br>
> >>>> Thanks so much,<br>
> >>>><br>
> >>>> Fande<br>
> >>>><br>
> >>><br>
> >>><br>
> >>> --<br>
> >>> What most experimenters take for granted before they begin their<br>
> >>> experiments is infinitely more interesting than any results to which their<br>
> >>> experiments lead.<br>
> >>> -- Norbert Wiener<br>
> >>><br>
> >>> <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> >>> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> >>><br>
> >><br>
> ><br>
> > --<br>
> > What most experimenters take for granted before they begin their<br>
> > experiments is infinitely more interesting than any results to which their<br>
> > experiments lead.<br>
> > -- Norbert Wiener<br>
> ><br>
> > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> > <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> ><br>
> ><br>
> ><br>
> <br>
<br>
</blockquote></div></div>