1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-24 00:45:52 +00:00

- link libc_pic.a when compiling with "-KPIC -static"

- link libc_p.a/lib_c_r.a when compiling with "-pg -static"
- fix unresolved symbols to make "-pg" and "-prof_gen" work

Submitted by:	marius@alchemy.franken.de
Approved by:	kris
This commit is contained in:
Alexander Leidinger 2002-09-22 13:05:51 +00:00
parent bed78f77e4
commit 8b67accbb2
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=67028
12 changed files with 282 additions and 36 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= icc
PORTVERSION= 6.0.1.304
PORTREVISION= 1
CATEGORIES= lang linux devel
MASTER_SITES=
DISTNAME= l_cc_p_6.0.1.304
@ -105,10 +106,11 @@ post-patch:
# \n-Qlocation,ld,/usr/bin\n\n-sox-\n
do-build:
# Fix unresolved references in libcxa.a, libimf.a and libunwind.a
@cd ${WRKSRC} && ${CC} ${CFLAGS} -c ${FILESDIR}/cxa_atexit.c \
${FILESDIR}/cxa_finalize.c ${FILESDIR}/errno_location.c \
${FILESDIR}/stderr.c && \
# Fix unresolved references
@cd ${WRKSRC} && ${CC} ${CFLAGS} -c ${FILESDIR}/assert_fail.c \
${FILESDIR}/cxa_atexit.c ${FILESDIR}/cxa_finalize.c \
${FILESDIR}/errno_location.c ${FILESDIR}/stderr.c \
${FILESDIR}/mcount.S && \
${AR} q opt/intel/compiler60/ia32/lib/libcxa.a *.o
# Some magic to be able to link
@${CC} ${CFLAGS} -o ${WRKSRC}/opt/intel/compiler60/ia32/bin/ld ${FILESDIR}/ld.c

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2002 Marius Strobl
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <err.h>
#include <stdlib.h>
void
__assert_fail(const char *failedexpr, const char *file, unsigned int line,
const char *fn)
{
warnx("assertion \"%s\" failed: file \"%s\", line %u%s%s%s", failedexpr,
file, line, fn ? ", function: \"" : "", fn ? fn : "",
fn ? "\"" : "");
abort();
}

View File

@ -143,8 +143,8 @@ int
main(int argc, char *argv[], char *envp[])
{
size_t i;
int bootstrap, cpp, dynamic, stlinserted, threaded;
char *prefix;
int bootstrap, cpp, dynamic, pic, gprof, stlinserted, threaded;
char *libc, *libc_r, *prefix;
struct arglist al;
if (argc == 1)
@ -154,7 +154,7 @@ main(int argc, char *argv[], char *envp[])
errx(1, "can't get PREFIX");
initarg(&al);
bootstrap = cpp = dynamic = stlinserted = threaded = 0;
bootstrap = cpp = dynamic = pic = gprof = stlinserted = threaded = 0;
#ifdef DEBUG
printf("input: ");
@ -185,6 +185,11 @@ main(int argc, char *argv[], char *envp[])
continue;
}
if (ARGCMP("-PIC")) {
pic++;
continue;
}
/*
* If the compiler was called with -static we shouldn't see
* "--dynamic-linker" here.
@ -217,12 +222,42 @@ main(int argc, char *argv[], char *envp[])
continue;
}
/*
* Link against libc_p when "-pg" was given, "/usr/lib/gcrt1.o"
* indicates this.
*/
if (ARGCMP("/usr/lib/gcrt1.o")) {
gprof++;
continue;
}
}
/*
* Use the appropriate libs for libc and libc_r when linking static
* and "-KPIC" or "-pg" where given.
*/
if (!dynamic && (pic || gprof)) {
/*
* Let libc_p win above libc_pic when both, "-KPIC" and "-pg",
* where given, GCC does the same.
*/
if (!gprof) {
libc = strdup("-lc_pic");
libc_r = strdup("-lc_r");
} else {
libc = strdup("-lc_p");
libc_r = strdup("-lc_r_p");
}
} else {
libc = strdup("-lc");
libc_r = strdup("-lc_r");
}
#ifdef DEBUG
printf("\ncpp: %s bootstrap: %s dynamic: %s threaded: %s\n",
cpp ? "YES" : "NO", bootstrap ? "YES" : "NO",
dynamic ? "YES" : "NO", threaded ? "YES" : "NO");
printf("\ncpp: %s bootstrap: %s dynamic: %s gprof: %s pic: %s "
"threaded: %s\n", cpp ? "YES" : "NO", bootstrap ? "YES" : "NO",
dynamic ? "YES" : "NO", gprof ? "YES" : "NO", pic ? "YES" : "NO",
threaded ? "YES" : "NO");
#endif
if (bootstrap && !cpp)
@ -230,7 +265,8 @@ main(int argc, char *argv[], char *envp[])
"-CPLUSPLUS");
for (i = 0; i < argc; i++) {
if (ARGCMP("-CPLUSPLUS") || ARGCMP("-BOOTSTRAPSTLPORT"))
if (ARGCMP("-CPLUSPLUS") || ARGCMP("-BOOTSTRAPSTLPORT") ||
ARGCMP("-PIC"))
continue;
/* prepend "-melf_i386" to the commandline */
@ -277,18 +313,23 @@ main(int argc, char *argv[], char *envp[])
* code (libcxa and libunwind depend on libc_r when compiling
* C++ source).
*/
if ((cpp || threaded) && ARGCMP("-lc")) {
if (ARGCMP("-lc")) {
if (al.argc > 0 &&
strncmp(al.argv[al.argc - 1], "-B", strlen("-B")))
addarg(&al,
dynamic ? "-Bdynamic" : "-Bstatic", 1);
if (cpp || threaded) {
#if __FreeBSD_version < 500016
addarg(&al, "-lc_r", 1);
addarg(&al, libc_r, 0);
#else
addarg(&al, "-lc", 1);
addarg(&al, dynamic ? "-Bdynamic" : "-Bstatic", 1);
addarg(&al, "-lc_r", 1);
addarg(&al, libc, 0);
addarg(&al,
dynamic ? "-Bdynamic" : "-Bstatic", 1);
addarg(&al, libc_r, 0);
#endif
} else {
addarg(&al, libc, 0);
}
continue;
}

34
lang/icc/files/mcount.S Normal file
View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2002 Marius Strobl
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
.text
.extern .mcount
.globl mcount
.type mcount,@function
mcount:
jmp .mcount

View File

@ -1,6 +1,6 @@
--- opt/intel/compiler60/ia32/bin/icc.orig Tue Aug 6 04:34:18 2002
+++ opt/intel/compiler60/ia32/bin/icc Tue Aug 6 04:46:51 2002
@@ -1,29 +1,49 @@
@@ -1,29 +1,52 @@
#!/bin/sh
-INTEL_LICENSE_FILE=<INSTALLDIR>/licenses;
@ -51,6 +51,9 @@
+ echo "Sorry, option '$val1' is not supported on FreeBSD."
+ exit 1
+ fi
+ if [ ${val1} = "-Kpic" ] || [ ${val1} = "-KPIC" ] ; then
+ set -- "$@" "-Qoption,ld,-PIC"
+ fi
+ set -- "$@" "$val1"
+ i=$(($i+1))
+ done

View File

@ -1,6 +1,6 @@
--- opt/intel/compiler60/ia32/bin/icpc.orig Fri Sep 6 02:18:03 2002
+++ opt/intel/compiler60/ia32/bin/icpc Tue Sep 10 18:32:59 2002
@@ -1,29 +1,42 @@
@@ -1,29 +1,45 @@
#!/bin/sh
-INTEL_LICENSE_FILE=<INSTALLDIR>/licenses;
@ -44,6 +44,9 @@
+ echo "Sorry, option '$val1' is not supported on FreeBSD."
+ exit 1
+ fi
+ if [ ${val1} = "-Kpic" ] || [ ${val1} = "-KPIC" ] ; then
+ set -- "$@" "-Qoption,ld,-PIC"
+ fi
+ set -- "$@" "$val1"
+ i=$(($i+1))
+ done

View File

@ -7,6 +7,7 @@
PORTNAME= icc
PORTVERSION= 6.0.1.304
PORTREVISION= 1
CATEGORIES= lang linux devel
MASTER_SITES=
DISTNAME= l_cc_p_6.0.1.304
@ -105,10 +106,11 @@ post-patch:
# \n-Qlocation,ld,/usr/bin\n\n-sox-\n
do-build:
# Fix unresolved references in libcxa.a, libimf.a and libunwind.a
@cd ${WRKSRC} && ${CC} ${CFLAGS} -c ${FILESDIR}/cxa_atexit.c \
${FILESDIR}/cxa_finalize.c ${FILESDIR}/errno_location.c \
${FILESDIR}/stderr.c && \
# Fix unresolved references
@cd ${WRKSRC} && ${CC} ${CFLAGS} -c ${FILESDIR}/assert_fail.c \
${FILESDIR}/cxa_atexit.c ${FILESDIR}/cxa_finalize.c \
${FILESDIR}/errno_location.c ${FILESDIR}/stderr.c \
${FILESDIR}/mcount.S && \
${AR} q opt/intel/compiler60/ia32/lib/libcxa.a *.o
# Some magic to be able to link
@${CC} ${CFLAGS} -o ${WRKSRC}/opt/intel/compiler60/ia32/bin/ld ${FILESDIR}/ld.c

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2002 Marius Strobl
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <err.h>
#include <stdlib.h>
void
__assert_fail(const char *failedexpr, const char *file, unsigned int line,
const char *fn)
{
warnx("assertion \"%s\" failed: file \"%s\", line %u%s%s%s", failedexpr,
file, line, fn ? ", function: \"" : "", fn ? fn : "",
fn ? "\"" : "");
abort();
}

View File

@ -143,8 +143,8 @@ int
main(int argc, char *argv[], char *envp[])
{
size_t i;
int bootstrap, cpp, dynamic, stlinserted, threaded;
char *prefix;
int bootstrap, cpp, dynamic, pic, gprof, stlinserted, threaded;
char *libc, *libc_r, *prefix;
struct arglist al;
if (argc == 1)
@ -154,7 +154,7 @@ main(int argc, char *argv[], char *envp[])
errx(1, "can't get PREFIX");
initarg(&al);
bootstrap = cpp = dynamic = stlinserted = threaded = 0;
bootstrap = cpp = dynamic = pic = gprof = stlinserted = threaded = 0;
#ifdef DEBUG
printf("input: ");
@ -185,6 +185,11 @@ main(int argc, char *argv[], char *envp[])
continue;
}
if (ARGCMP("-PIC")) {
pic++;
continue;
}
/*
* If the compiler was called with -static we shouldn't see
* "--dynamic-linker" here.
@ -217,12 +222,42 @@ main(int argc, char *argv[], char *envp[])
continue;
}
/*
* Link against libc_p when "-pg" was given, "/usr/lib/gcrt1.o"
* indicates this.
*/
if (ARGCMP("/usr/lib/gcrt1.o")) {
gprof++;
continue;
}
}
/*
* Use the appropriate libs for libc and libc_r when linking static
* and "-KPIC" or "-pg" where given.
*/
if (!dynamic && (pic || gprof)) {
/*
* Let libc_p win above libc_pic when both, "-KPIC" and "-pg",
* where given, GCC does the same.
*/
if (!gprof) {
libc = strdup("-lc_pic");
libc_r = strdup("-lc_r");
} else {
libc = strdup("-lc_p");
libc_r = strdup("-lc_r_p");
}
} else {
libc = strdup("-lc");
libc_r = strdup("-lc_r");
}
#ifdef DEBUG
printf("\ncpp: %s bootstrap: %s dynamic: %s threaded: %s\n",
cpp ? "YES" : "NO", bootstrap ? "YES" : "NO",
dynamic ? "YES" : "NO", threaded ? "YES" : "NO");
printf("\ncpp: %s bootstrap: %s dynamic: %s gprof: %s pic: %s "
"threaded: %s\n", cpp ? "YES" : "NO", bootstrap ? "YES" : "NO",
dynamic ? "YES" : "NO", gprof ? "YES" : "NO", pic ? "YES" : "NO",
threaded ? "YES" : "NO");
#endif
if (bootstrap && !cpp)
@ -230,7 +265,8 @@ main(int argc, char *argv[], char *envp[])
"-CPLUSPLUS");
for (i = 0; i < argc; i++) {
if (ARGCMP("-CPLUSPLUS") || ARGCMP("-BOOTSTRAPSTLPORT"))
if (ARGCMP("-CPLUSPLUS") || ARGCMP("-BOOTSTRAPSTLPORT") ||
ARGCMP("-PIC"))
continue;
/* prepend "-melf_i386" to the commandline */
@ -277,18 +313,23 @@ main(int argc, char *argv[], char *envp[])
* code (libcxa and libunwind depend on libc_r when compiling
* C++ source).
*/
if ((cpp || threaded) && ARGCMP("-lc")) {
if (ARGCMP("-lc")) {
if (al.argc > 0 &&
strncmp(al.argv[al.argc - 1], "-B", strlen("-B")))
addarg(&al,
dynamic ? "-Bdynamic" : "-Bstatic", 1);
if (cpp || threaded) {
#if __FreeBSD_version < 500016
addarg(&al, "-lc_r", 1);
addarg(&al, libc_r, 0);
#else
addarg(&al, "-lc", 1);
addarg(&al, dynamic ? "-Bdynamic" : "-Bstatic", 1);
addarg(&al, "-lc_r", 1);
addarg(&al, libc, 0);
addarg(&al,
dynamic ? "-Bdynamic" : "-Bstatic", 1);
addarg(&al, libc_r, 0);
#endif
} else {
addarg(&al, libc, 0);
}
continue;
}

34
lang/icc7/files/mcount.S Normal file
View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2002 Marius Strobl
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
.text
.extern .mcount
.globl mcount
.type mcount,@function
mcount:
jmp .mcount

View File

@ -1,6 +1,6 @@
--- opt/intel/compiler60/ia32/bin/icc.orig Tue Aug 6 04:34:18 2002
+++ opt/intel/compiler60/ia32/bin/icc Tue Aug 6 04:46:51 2002
@@ -1,29 +1,49 @@
@@ -1,29 +1,52 @@
#!/bin/sh
-INTEL_LICENSE_FILE=<INSTALLDIR>/licenses;
@ -51,6 +51,9 @@
+ echo "Sorry, option '$val1' is not supported on FreeBSD."
+ exit 1
+ fi
+ if [ ${val1} = "-Kpic" ] || [ ${val1} = "-KPIC" ] ; then
+ set -- "$@" "-Qoption,ld,-PIC"
+ fi
+ set -- "$@" "$val1"
+ i=$(($i+1))
+ done

View File

@ -1,6 +1,6 @@
--- opt/intel/compiler60/ia32/bin/icpc.orig Fri Sep 6 02:18:03 2002
+++ opt/intel/compiler60/ia32/bin/icpc Tue Sep 10 18:32:59 2002
@@ -1,29 +1,42 @@
@@ -1,29 +1,45 @@
#!/bin/sh
-INTEL_LICENSE_FILE=<INSTALLDIR>/licenses;
@ -44,6 +44,9 @@
+ echo "Sorry, option '$val1' is not supported on FreeBSD."
+ exit 1
+ fi
+ if [ ${val1} = "-Kpic" ] || [ ${val1} = "-KPIC" ] ; then
+ set -- "$@" "-Qoption,ld,-PIC"
+ fi
+ set -- "$@" "$val1"
+ i=$(($i+1))
+ done