Hi,

On 10/05/2015 01:56 PM, Mike Stump wrote:

I don't think this is appropriate.  The design is for remote host testing to 
have the compete shape of an installed compiler as I recall.  When it does, it 
then is indistinguishable from an installed compiler, and when it is installed, 
then no -L nor -B flag is necessary for it to work.  The link_flags only exists 
to add these flags, not the -l flag.  That is the thing that is wrong.  Remove 
that, and add

  "libs=-latomic”

to someplace that will inject that option.  I stole that line from objc.exp:

   append options "libs=-lobjc”

or otherwise unconditionally put -latomic on the link line (some place that 
isn’t protected by is_remote host).


I've revised the patch based on the review comments from yourself,
Bernd, and Joseph (thank you for your comments).

I've moved the addition of the '-latomic' from atomic_link_flags to
atomic_init. Now atomic_link_flags just finds the library location
and sets the appropriate variables. Additional changes were added
to use the '-latomic' addition only for atomic testing.

OK?

Thanks!
Jim



diff --git a/gcc/testsuite/lib/atomic-dg.exp b/gcc/testsuite/lib/atomic-dg.exp
index fe24127..0640f3c 100644
--- a/gcc/testsuite/lib/atomic-dg.exp
+++ b/gcc/testsuite/lib/atomic-dg.exp
@@ -48,7 +48,6 @@ proc atomic_link_flags { paths } {
 
     set_ld_library_path_env_vars
 
-    append flags " -latomic "
     return "$flags"
 }
 
@@ -61,6 +60,7 @@ proc atomic_init { args } {
     global ALWAYS_CXXFLAGS
     global TOOL_OPTIONS
     global atomic_saved_TEST_ALWAYS_FLAGS
+    global atomic_saved_ALWAYS_CXXFLAGS
 
     set link_flags ""
     if ![is_remote host] {
@@ -71,10 +71,13 @@ proc atomic_init { args } {
 	}
     }
 
+    append link_flags " -latomic "
+
     if [info exists TEST_ALWAYS_FLAGS] {
 	set atomic_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
     }
     if [info exists ALWAYS_CXXFLAGS] {
+	set atomic_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS
 	set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS]
     } else {
 	if [info exists TEST_ALWAYS_FLAGS] {
@@ -95,11 +98,16 @@ proc atomic_init { args } {
 proc atomic_finish { args } {
     global TEST_ALWAYS_FLAGS
     global atomic_saved_TEST_ALWAYS_FLAGS
+    global atomic_saved_ALWAYS_CXXFLAGS
 
-    if [info exists atomic_saved_TEST_ALWAYS_FLAGS] {
-	set TEST_ALWAYS_FLAGS $atomic_saved_TEST_ALWAYS_FLAGS
+    if [info exists atomic_saved_ALWAYS_CXXFLAGS] {
+	set ALWAYS_CXXFLAGS $atomic_saved_ALWAYS_CXXFLAGS
     } else {
-	unset TEST_ALWAYS_FLAGS
+	if [info exists atomic_saved_TEST_ALWAYS_FLAGS] {
+	  set TEST_ALWAYS_FLAGS $atomic_saved_TEST_ALWAYS_FLAGS
+	} else {
+	  unset TEST_ALWAYS_FLAGS
+	}
     }
     clear_effective_target_cache
 }

Reply via email to