<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">
<div>Also works with PathScale EKOPath Compiler Suite installed on MCS machines. </div>
<div><br>
</div>
$ pathcc -c check-pic.c -fPIC<br>
$ pathcc -c check-pic.c<br>
check-pic.c:2:2: error: "no-PIC"<br>
#error "no-PIC"<br>
^<br>
1 error generated.
<div><br clear="all">
<div>
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">--Junchao Zhang</div>
</div>
</div>
<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, May 28, 2019 at 1:54 PM Smith, Barry F. via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@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">
<br>
Works for Intel and PGI compiles (the version I checked)<br>
<br>
bsmith@es:~$ pgcc check-pic.c -PIC<br>
pgcc-Error-Unknown switch: -PIC<br>
bsmith@es:~$ pgcc check-pic.c -fPIC<br>
bsmith@es:~$ pgcc check-pic.c <br>
PGC-F-0249-#error -- "no-PIC" (check-pic.c: 2)<br>
PGC/x86-64 Linux 19.3-0: compilation aborted<br>
bsmith@es:~$ icc check-pic.c <br>
check-pic.c(2): error: #error directive: "no-PIC"<br>
#error "no-PIC"<br>
^<br>
<br>
compilation aborted for check-pic.c (code 2)<br>
bsmith@es:~$ icc check-pic.c -PIC<br>
icc: command line warning #10006: ignoring unknown option '-PIC'<br>
check-pic.c(2): error: #error directive: "no-PIC"<br>
#error "no-PIC"<br>
^<br>
<br>
compilation aborted for check-pic.c (code 2)<br>
bsmith@es:~$ icc check-pic.c -fPIC<br>
bsmith@es:~$ <br>
<br>
<br>
You are the man!<br>
<br>
<br>
> On May 28, 2019, at 12:29 PM, Lisandro Dalcin via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
> <br>
> <br>
> <br>
> On Tue, 28 May 2019 at 18:19, Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:<br>
> Lisandro Dalcin via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> writes:<br>
> <br>
> > On Tue, 28 May 2019 at 17:31, Balay, Satish via petsc-users <<br>
> > <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
> ><br>
> >> Configure.log shows '--with-pic=1' - hence this error.<br>
> >><br>
> >> Remove '--with-pic=1' and retry.<br>
> >><br>
> >><br>
> > Nonsense. Why this behavior? Building a static library with PIC code is a<br>
> > perfectly valid use case.<br>
> <br>
> And that's what will happen because Inge passed -fPIC in CFLAGS et al.<br>
> <br>
> Do you know how we could confirm that PIC code is generated without<br>
> attempting to use shared libraries?<br>
> <br>
> <br>
> I know how to do it with the `readelf` command for ELF objects. I even know how to do it compile-time for GCC and clang. Maybe Intel also works this way. I do not know about a general solution, though.<br>
> <br>
> $ cat check-pic.c <br>
> #ifndef __PIC__<br>
> #error "no-PIC"<br>
> #endif<br>
> <br>
> $ gcc -c check-pic.c -fPIC<br>
> <br>
> $ clang -c check-pic.c -fPIC<br>
> <br>
> $ gcc -c check-pic.c<br>
> check-pic.c:2:2: error: #error "no-PIC"<br>
> 2 | #error "no-PIC"<br>
> | ^~~~~<br>
> <br>
> $ clang -c check-pic.c<br>
> check-pic.c:2:2: error: "no-PIC"<br>
> #error "no-PIC"<br>
> ^<br>
> 1 error generated.<br>
> <br>
> -- <br>
> Lisandro Dalcin<br>
> ============<br>
> Research Scientist<br>
> Extreme Computing Research Center (ECRC)<br>
> King Abdullah University of Science and Technology (KAUST)<br>
> <a href="http://ecrc.kaust.edu.sa/" rel="noreferrer" target="_blank">http://ecrc.kaust.edu.sa/</a><br>
<br>
</blockquote>
</div>
</body>
</html>