Opened 10 years ago

Closed 10 years ago

#6887 closed Bugs (fixed)

Hardcoded path to g++ in gcc.mak and gcc-shared.mak for regex

Reported by: Morten Rasmussen <mortenrasmussen@…> Owned by: John Maddock
Milestone: To Be Determined Component: regex
Version: Boost 1.49.0 Severity: Problem
Keywords: gcc makefile g++ path Cc:

Description

The makefiles gcc.mak and gcc-shared.mak in boost/libs/regex/build both contain the lines

CXX=g++ LINKER=g++ -shared

which means that the compiler will pick the g++ defined by the PATH variable.

This is unfortunate if you have multiple gcc version on the machine and intend to link boost regex with modules compiled with another g++ version than the one defined by PATH.

To fix this, I suggest that these lines are changed to

CXX?=g++ LINKER=$(CXX) -shared

so that a CXX value passed to the makefile will prevail, and "g++" is still if no value is passed.

In other words: this suggestion adds the option of passing an alternative CXX value to the makefile - the suggestion will be backward compatible by working as before if no value is passed.

The changes in diff format:

diff gcc.mak.orig gcc.mak 24,25c24,25 < CXX=g++ < LINKER=g++ -shared ---

CXX?=g++ LINKER=$(CXX) -shared

diff gcc-shared.mak.orig gcc-shared.mak 24,25c24,25 < CXX=g++ < LINKER=g++ -shared ---

CXX?=g++ LINKER=$(CXX) -shared

Change History (2)

comment:1 by Morten Rasmussen <mortenrasmussen@…>, 10 years ago

(Sorry for lousy formatting - read below instead)

The makefiles gcc.mak and gcc-shared.mak in boost/libs/regex/build both contain the lines

CXX=g++
LINKER=g++ -shared

which means that the compiler will pick the g++ defined by the PATH variable.

This is unfortunate if you have multiple gcc version on the machine and intend to link boost regex with modules compiled with another g++ version than the one defined by PATH.

To fix this, I suggest that these lines are changed to

CXX?=g++
LINKER=$(CXX) -shared

so that a CXX value passed to the makefile will prevail, and "g++" is still if no value is passed.

In other words: this suggestion adds the option of passing an alternative CXX value to the makefile - the suggestion will be backward compatible by working as before if no value is passed.

The changes in diff format:

diff gcc.mak.orig gcc.mak
24,25c24,25
< CXX=g++
< LINKER=g++ -shared
---
> CXX?=g++
> LINKER=$(CXX) -shared
 
diff gcc-shared.mak.orig gcc-shared.mak
24,25c24,25
< CXX=g++
< LINKER=g++ -shared
---
> CXX?=g++
> LINKER=$(CXX) -shared

comment:2 by John Maddock, 10 years ago

Resolution: fixed
Status: newclosed

(In [78424]) Change gcc makefile variable usage. Regenerate makesfiles. Fixes #6887

Note: See TracTickets for help on using tickets.