[Lsb-messages] /var/www/bzr/lsb/devel/build_env r2191: improve lsbcc debugging support slightly
Mats Wichmann
mats at linuxfoundation.org
Tue Feb 4 18:03:58 UTC 2014
------------------------------------------------------------
revno: 2191
committer: Mats Wichmann <mats at linuxfoundation.org>
branch nick: build_env
timestamp: Tue 2014-02-04 11:03:58 -0700
message:
improve lsbcc debugging support slightly
added:
lsbdev-cc/README
modified:
lsbdev-cc/lsbcc.c
lsbdev-cc/lsbcc_argv.c
lsbdev-cc/lsbcc_argv.h
lsbdev-cc/lsbcpp.c
package/Makefile
-------------- next part --------------
=== added file 'lsbdev-cc/README'
--- a/lsbdev-cc/README 1970-01-01 00:00:00 +0000
+++ b/lsbdev-cc/README 2014-02-04 18:03:58 +0000
@@ -0,0 +1,16 @@
+This is the compiler front-end tool for the LSB SDK.
+
+It munches the command line to produce something suitable for passing to
+the back-end compiler, normally gcc, although there's at least nominal
+support for Intel's icc compiler.
+
+This tool is only interesting in the presence of LSB SDK headers and
+build-time libraries ("stub libraries"). While the normal situation is
+to put LSB SDK materials in /opt/lsb, the default in this directory
+(set in the Makefile) is to build as if files were going in /usr/local,
+normal for most pieces of add-on software. If experimenting with lsbcc
+to debug an environment that's already installed, the usual path options
+can be used, for example:
+
+ INSTALL_ROOT=/opt/lsb make
+
=== modified file 'lsbdev-cc/lsbcc.c'
--- a/lsbdev-cc/lsbcc.c 2014-01-29 17:30:23 +0000
+++ b/lsbdev-cc/lsbcc.c 2014-02-04 18:03:58 +0000
@@ -75,10 +75,9 @@
#include "elf_utils.h"
/*
- * These are the catagories of options that we are going to be grouping
+ * These are the categories of options that we are going to be grouping
* together.
*/
-
struct argvgroup *proginterp;
struct argvgroup *target;
struct argvgroup *options;
@@ -94,7 +93,6 @@
* Find out if we are being used for C++. If so, we need to do a couple
* of extra things.
*/
-
#define LSBCC 0
#define LSBCPLUS 1
@@ -113,35 +111,18 @@
char incpath[PATH_MAX];
char cxxincpath[PATH_MAX];
char libpath[PATH_MAX];
-/* 'Normal' version name */
-char *lsbcc_lsbversion = DEFAULT_LSB_VERSION;
-/* Version name with dot removed */
-char *lsbversion_option;
+char *lsbcc_lsbversion = DEFAULT_LSB_VERSION; /* 'Normal' version name */
+char *lsbversion_option; /* Version name with dot removed */
/* Index in the lsb_libs array corresponding to the target LSB version */
int lsbversion_index = 0;
-
-/*
- * Debugging interface: Set the environment variable LSBCC_DEBUG to a value
- * that corresponds to the bits defined below.
- */
-
-#define DEBUG_ENV_OVERRIDES 0x0001
-#define DEBUG_ARGUMENTS 0x0002
-#define DEBUG_RECOGNIZED_ARGS 0x0004
-#define DEBUG_UNRECOGNIZED_ARGS 0x0008
-#define DEBUG_INCLUDE_CHANGES 0x0010
-#define DEBUG_LIB_CHANGES 0x0020
-#define DEBUG_MODIFIED_ARGS 0x0040
-
-#define WARN_LIB_CHANGES 0x0001
-
-int lsbcc_debug = 0; /* off by default, autoconf fails on msg to stderr */
-int cpp_only = 0; /* another flag to help autoconf */
+/* Debugging interface: Set LSBCC_DEBUG to a bitmask (see lsbcc_argv.h) */
+int lsbcc_debug = 0; /* Default to none. autoconf likes things quiet. */
+int cpp_only = 0; /* another flag to help autoconf */
int lsbcc_warn = 0;
int lsbcc_buildingshared = 0;
/*
- * State variable to determine if we need to add -Wl,-Bdynamic before an LSB lib.
+ * State variable to determine if we need to add -Wl,-Bdynamic before an LSB lib
*/
int b_dynamic = 1;
@@ -153,7 +134,6 @@
/*
* Lookup table for extra include paths for each LSB version.
*/
-
char *lsb30_version_include_paths[] = { NULL };
char *lsb31_version_include_paths[] = { BASE_PATH "/include/libpng12", NULL };
char *lsb32_version_include_paths[] = { BASE_PATH "/include/libpng12", NULL };
@@ -187,13 +167,15 @@
for (i = 0; i < lsblibs->numargv; i++) {
if (strcmp(lsblibs->argv[i], val) == 0) {
if (!b_dynamic) {
+ if (lsbcc_debug & DEBUG_LIB_CHANGES)
+ fprintf(stderr, "Appending -Wl,-Bdynamic\n");
argvaddstring(userlibs, "-Wl,-Bdynamic");
b_dynamic = 1;
}
argvaddstring(userlibs, strdup(buf));
/* If it's pthread, add pthread_nonshared. */
- if (strcmp("pthread", val) == 0) {
+ if (strcmp(val, "pthread") == 0) {
if (lsbcc_debug & DEBUG_LIB_CHANGES)
fprintf(stderr, "Appending -lpthread_nonshared\n");
argvaddstring(userlibs, "-lpthread_nonshared");
@@ -211,6 +193,8 @@
fprintf(stderr, "Warning: forcing %s to be linked statically\n", val);
if (b_dynamic) {
+ if (lsbcc_debug & DEBUG_LIB_CHANGES)
+ fprintf(stderr, "Appending -Wl,-Bstatic\n");
argvaddstring(userlibs, "-Wl,-Bstatic");
b_dynamic = 0;
}
@@ -1007,18 +991,18 @@
struct stat st_buf;
/*
- * Initialize various argv groups.
+ * Initialize the argv groups.
*/
- gccstartargs = argvinit();
- lsblibs = argvinit();
- proginterp = argvinit();
- target = argvinit();
- options = argvinit();
- incpaths = argvinit();
- libpaths = argvinit();
- userlibs = argvinit();
- syslibs = argvinit();
- gccargs = argvinit();
+ gccstartargs = argvinit("gccstartargs");
+ lsblibs = argvinit("lsblibs");
+ proginterp = argvinit("proginterp");
+ target = argvinit("target");
+ options = argvinit("options");
+ incpaths = argvinit("incpaths");
+ libpaths = argvinit("libpaths");
+ userlibs = argvinit("userlibs");
+ syslibs = argvinit("syslibs");
+ gccargs = argvinit("gccargs");
/* Determine if we are being called for C or C++ */
if (strcmp(basename(argv[0]), "lsbc++") == 0) {
@@ -1306,8 +1290,7 @@
case 0:
found_gcc_arg = 1;
if (lsbcc_debug & DEBUG_RECOGNIZED_ARGS) {
- fprintf(stderr, "option0: -%s",
- long_options[option_index].name);
+ fprintf(stderr, "option0: -%s",long_options[option_index].name);
if (optarg) {
fprintf(stderr, " with arg %s", optarg);
}
@@ -1336,8 +1319,7 @@
/* special case: file fed to stdin */
if (strcmp(optarg, "-") == 0) {
if (lsbcc_debug & DEBUG_RECOGNIZED_ARGS) {
- fprintf(stderr, "option1: %s, process stdin\n",
- optarg);
+ fprintf(stderr, "option1: %s, process stdin\n", optarg);
}
found_file = 1;
}
@@ -1474,7 +1456,7 @@
case 'l':
found_gcc_arg = 1;
if (lsbcc_debug & DEBUG_RECOGNIZED_ARGS)
- fprintf(stderr, "option: - %s\n", optarg);
+ fprintf(stderr, "option: -l %s\n", optarg);
found_l_opt = 1;
process_opt_l(optarg);
break;
@@ -1492,6 +1474,8 @@
* and have to stay with these flags. stuff it onto the
* unrecognized list, although of course we did recognize this
*/
+ if (lsbcc_debug & DEBUG_RECOGNIZED_ARGS)
+ fprintf(stderr, "option: %s\n", argv[optind - 1]);
argvaddstring(options, argv[optind - 1]);
break;
}
@@ -1661,6 +1645,9 @@
* Set up per-LSB-version include paths.
*/
for (i = 0; lsb_version_include_paths[lsbversion_index][i] != NULL; i++) {
+ if (lsbcc_debug & DEBUG_INCLUDE_CHANGES)
+ fprintf(stderr, "Prepending %s to system include path\n",
+ lsb_version_include_paths[lsbversion_index][i]);
argvadd(incpaths, "I", lsb_version_include_paths[lsbversion_index][i]);
}
@@ -1726,8 +1713,7 @@
if (!no_link) {
if (lsbcc_debug & DEBUG_LIB_CHANGES) {
- fprintf(stderr, "Prepending %s to the linker path\n",
- gccbasedir);
+ fprintf(stderr, "Prepending %s to the linker path\n", gccbasedir);
}
argvadd(syslibs, "L", gccbasedir);
@@ -1865,8 +1851,7 @@
*/
argvappend(gccargs, incpaths);
if (lsbcc_debug & DEBUG_INCLUDE_CHANGES)
- fprintf(stderr, "Prepending %s to system include path\n",
- incpath);
+ fprintf(stderr, "Prepending %s to system include path\n", incpath);
argvadd(gccargs, "isystem", incpath);
if (lsbccmode == LSBCPLUS) {
@@ -1928,7 +1913,7 @@
if (auto_pthread) {
if (lsbcc_debug & DEBUG_LIB_CHANGES) {
fprintf(stderr,
- "Appending -lpthread -lpthread_nonshared to the library list\n");
+ "Appending -lpthread -lpthread_nonshared to the library list due to auto_pthread\n");
}
if (!b_dynamic && !force_static) {
argvaddstring(gccargs, "-Wl,-Bdynamic");
=== modified file 'lsbdev-cc/lsbcc_argv.c'
--- a/lsbdev-cc/lsbcc_argv.c 2012-04-23 14:48:53 +0000
+++ b/lsbdev-cc/lsbcc_argv.c 2014-02-04 18:03:58 +0000
@@ -26,23 +26,22 @@
* Create an abstract data type to maintain the options that are collected
* into groups, and then put together to pass to gcc.
*/
-struct argvgroup *argvinit(void)
+struct argvgroup *argvinit(const char *name)
{
struct argvgroup *ag;
- if ((ag =
- (struct argvgroup *) malloc(sizeof(struct argvgroup))) == NULL) {
+ if ((ag = (struct argvgroup *) malloc(sizeof(struct argvgroup))) == NULL) {
fprintf(stderr, "Unable to allocate memory for a new argvgroup\n");
exit(2);
}
- if ((ag->argv =
- (char **) malloc(sizeof(char *) * ARGVCHUNKSIZE)) == NULL) {
- fprintf(stderr, "Unable to allocate memory for a argv items\n");
+ if ((ag->argv = (char **) malloc(sizeof(char *) * ARGVCHUNKSIZE)) == NULL) {
+ fprintf(stderr, "Unable to allocate memory for argv items\n");
exit(2);
}
ag->numargv = 0;
ag->maxargv = ARGVCHUNKSIZE;
+ ag->groupname = strdup(name);
return ag;
}
@@ -69,6 +68,8 @@
}
}
+ if (lsbcc_debug & DEBUG_LISTADDS)
+ fprintf(stderr, "%s += %s\n", ag->groupname, str);
ag->argv[ag->numargv++] = str;
}
@@ -90,9 +91,8 @@
strcat(dashopt, opt);
argvaddstring(ag, dashopt);
- if (val) {
- ag->argv[ag->numargv++] = val;
- }
+ if (val)
+ argvaddstring(ag, val);
}
void argvappend(struct argvgroup *to, struct argvgroup *from)
=== modified file 'lsbdev-cc/lsbcc_argv.h'
--- a/lsbdev-cc/lsbcc_argv.h 2012-03-12 17:46:29 +0000
+++ b/lsbdev-cc/lsbcc_argv.h 2014-02-04 18:03:58 +0000
@@ -14,11 +14,12 @@
int numargv;
int maxargv;
char **argv;
+ char *groupname; /* for debugging */
};
#define ARGVCHUNKSIZE 100
-struct argvgroup *argvinit(void);
+struct argvgroup *argvinit(const char *name);
void argvreset(struct argvgroup *ag);
@@ -40,5 +41,21 @@
void argvprint(struct argvgroup *ag);
-/* end lsbcc.h */
+/*
+ * Debugging interface: Set the environment variable LSBCC_DEBUG to a value
+ * that corresponds to the bits defined below.
+ * These flags are shared between lsbcc and lsbcpp so moved here
+ */
+#define DEBUG_ENV_OVERRIDES 0x0001
+#define DEBUG_ARGUMENTS 0x0002
+#define DEBUG_RECOGNIZED_ARGS 0x0004
+#define DEBUG_UNRECOGNIZED_ARGS 0x0008
+#define DEBUG_INCLUDE_CHANGES 0x0010
+#define DEBUG_LIB_CHANGES 0x0020
+#define DEBUG_MODIFIED_ARGS 0x0040
+#define DEBUG_LISTADDS 0x0080
+
+#define WARN_LIB_CHANGES 0x0001
+
+extern int lsbcc_debug;
#endif
=== modified file 'lsbdev-cc/lsbcpp.c'
--- a/lsbdev-cc/lsbcpp.c 2014-01-02 16:38:30 +0000
+++ b/lsbdev-cc/lsbcpp.c 2014-02-04 18:03:58 +0000
@@ -58,26 +58,10 @@
char incpath[PATH_MAX];
char cxxincpath[PATH_MAX];
-/* 'Normal' version name */
-char *lsbcc_lsbversion = DEFAULT_LSB_VERSION;
-/* Version name with dot removed */
-char *lsbversion_option;
-
-/*
- * Debugging interface: Set the environment variable LSBCC_DEBUG to a value
- * that corresponds to the bits defined below.
- */
-#define DEBUG_ENV_OVERRIDES 0x0001
-#define DEBUG_ARGUMENTS 0x0002
-#define DEBUG_RECOGNIZED_ARGS 0x0004
-#define DEBUG_UNRECOGNIZED_ARGS 0x0008
-#define DEBUG_INCLUDE_CHANGES 0x0010
-#define DEBUG_LIB_CHANGES 0x0020
-#define DEBUG_MODIFIED_ARGS 0x0040
-
-#define WARN_LIB_CHANGES 0x0001
-
-int lsbcc_debug = 0; /* Default to none. autocon likes things to be quiet. */
+char *lsbcc_lsbversion = DEFAULT_LSB_VERSION; /* 'Normal' version name */
+char *lsbversion_option; /* Version name with dot removed */
+/* Debugging interface: Set LSBCC_DEBUG to a bitmask (see lsbcc_argv.h) */
+int lsbcc_debug = 0; /* Default to none. autoconf likes things quiet. */
int lsbcc_warn = 0;
int lsbcc_buildingshared = 0;
@@ -180,8 +164,8 @@
/*
* Initialize various argv groups.
*/
- cppargs = argvinit();
- options = argvinit();
+ cppargs = argvinit("cppargs");
+ options = argvinit("options");
/*
* Set up the paths we will need
=== modified file 'package/Makefile'
--- a/package/Makefile 2014-02-01 21:46:39 +0000
+++ b/package/Makefile 2014-02-04 18:03:58 +0000
@@ -42,11 +42,11 @@
# Should have leading "."
# a big number (80-99) is leading up to the next minor spec
# build_env is version-independent so can wait till late to bump this
-SUB_VERSION=.59
+SUB_VERSION=.60
# We define this here instead of directly in the spec file as
# we need to be able to work out what the produced rpm files will be called
-RPM_PACKAGE_RELEASE=2
+RPM_PACKAGE_RELEASE=1
# Initialize LIB64 to proper value for 64-bit architectures
export LIB64:=$(shell case `uname -m` in (ppc64 | s390x | x86_64) echo 64 ;; esac)
More information about the lsb-messages
mailing list