Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extconf.rb #11

Open
rinkevichjm opened this issue May 28, 2015 · 17 comments
Open

extconf.rb #11

rinkevichjm opened this issue May 28, 2015 · 17 comments

Comments

@rinkevichjm
Copy link

prebuilt versions of ruby sometimes contain paths to nonstandard folders. need removing in $LDFLAGS
clang on osx masquerades as gcc need to test output of -v
WX uses 3 C++tr1 header versus C++11 header flags that need testing for to set (twice for 2 of them).
--------diffs ----------
@@ -20,8 +20,8 @@ if(wx_config = find_executable('wx-config'))
abort("wx version outdated, please update to 3.0.0 or newer")
end

ruby_cc = CONFIG["CC"]
ruby_cxx = CONFIG["CXX"]
ruby_cc = RbConfig::CONFIG["CC"]
ruby_cxx = RbConfig::CONFIG["CXX"]
# An ruby extension does need to be build against
# the same compiler as ruby was
unless ruby_cc && find_executable(ruby_cc)

@@ -32,19 +32,67 @@ if(wx_config = find_executable('wx-config'))
end

cc = `#{wx_config} --cc`.chomp
unless cc == ruby_cc
    abort("CC compiler missmatch %s == %s" % [cc, ruby_cc])
end

cxx = `#{wx_config} --cxx`.chomp
unless cxx == ruby_cxx
    abort("CXX compiler missmatch %s == %s" % [cxx, ruby_cxx])
    cxxversion_wx = `#{cxx} -v 2>&1`.split("\n")
    cxxversion_rb = `#{ruby_cxx} -v 2>&1`.split("\n")
    ccversion_wx = `#{cc} -v 2>&1`.split("\n")
    ccversion_rb = `#{ruby_cc} -v 2>&1`.split("\n")
    puts ccversion_wx[0],ccversion_rb[0]
unless ccversion_rb.include?(ccversion_wx[0])
    abort("CC compiler missmatch %s == %s" % [ccversion_wx, ccversion_rb])
end
unless cxxversion_rb.include?(cxxversion_wx[0])
    abort("CXX compiler missmatch %s == %s" % [cxxversion_wx,cxxversion_rb])
end

#earlier versions of ruby does not have that constant
$CXXFLAGS = CONFIG["CXXFLAGS"] unless defined?($CXXFLAGS)

#for some function add the base classes
#remove bad paths in flags
rmnonpaths = lambda {|x|
    if (x[0,2]=="-L" ||x[0,2]=="-I") then
        if File.exist?(x[2,x.length-2]) then
            x
        else
            nil
        end
    else
        x
    end
}
if (RbConfig::CONFIG["CXXFLAGS"]) then
    $CXXFLAGS = RbConfig::CONFIG["CXXFLAGS"]
    $CXXFLAGS=$CXXFLAGS.split()
    $CXXFLAGS.map!(&rmnonpaths)
end
if (RbConfig::CONFIG["CPPFLAGS"]) then
    $CPPFLAGS = RbConfig::CONFIG["CXXFLAGS"]
    $CPPFLAGS=$CPPFLAGS.split()
    $CPPFLAGS.map!(&rmnonpaths)
end
if (RbConfig::CONFIG["CCFLAGS"]) then
    $CCFLAGS = RbConfig::CONFIG["CXXFLAGS"]
    $CCFLAGS=$CCFLAGS.split()
    $CCFLAGS.map!(&rmnonpaths)
end
if (RbConfig::CONFIG["LDFLAGS"]) then
    $LDFLAGS = RbConfig::CONFIG["CXXFLAGS"]
    $LDFLAGS=$LDFLAGS.split()
    $LDFLAGS.map!(&rmnonpaths)
end
if ($CXXFLAGS) then
    $CXXFLAGS=$CXXFLAGS.join(" ")
end
if ($CPPFLAGS) then
    $CPPFLAGS=$CPPFLAGS.join(" ")
end
if ($CCFLAGS) then
    $CCFLAGS=$CCFLAGS.join(" ")
end
if ($LDFLAGS) then
    $LDFLAGS=$LDFLAGS.join(" ")
end
$CXXFLAGS = RbConfig::CONFIG["CXXFLAGS"] unless defined?($CXXFLAGS)
#for some function add the base classes
extra_libs = []
case `#{wx_config} --basename`
when /gtk2/

@@ -56,30 +104,52 @@ if(wx_config = find_executable('wx-config'))
extra_libs.each {|l|
pkg = pkg_config(l)
#because pkg forgot to add the include paths to cxx flags
puts L
puts pkg[0]
$CXXFLAGS << " " << pkg[0] if pkg && !$CXXFLAGS[pkg[0]]
}

all = " -fvisibility-inlines-hidden"
$CFLAGS << all << " -x c++ -g -Wall "
$CXXFLAGS << all << " -g -Wall "
$CPPFLAGS << all << " -g "
$CPPFLAGS << all << " -g -x c++ "
$LDFLAGS << all << " "
#set up special flags for testing
moreflags = ""
with_cflags(" -x c++ ") {
  moreflags += " -DHAVE_TYPE_TRAITS " if have_header("type_traits")
  moreflags += " -DHAVE_TR1_TYPE_TRAITS " if have_header("tr1/type_traits")
  moreflags += " -DHAVE_STD_UNORDERED_MAP " if have_header("unordered_map")
  moreflags += " -DHAVE_TR1_UNORDERED_MAP " if have_header("tr1/unordered_map")
    }

# add the wx-config flags
$CFLAGS << `#{wx_config} --cflags`.chomp
$CXXFLAGS << `#{wx_config} --cxxflags`.chomp
$CPPFLAGS << `#{wx_config} --cppflags`.chomp
$LDFLAGS << `#{wx_config} --libs all`.chomp

puts $LDFLAGS
# TODO add extra check if a lib of wx is missing

with_cflags(" -x c++ ") {
with_cflags(" -x c++ "+moreflags) {
    # need c++ for some of the tests
    RbConfig::CONFIG["CC"] = CONFIG["CXX"]

    have_header("wx/preferences.h")

    #check for better Bind commmand
    CONFIG["CC"] = CONFIG["CXX"]
    #C++98tr1 c++11 differences
    have_header("type_traits")
    have_header("tr1/type_traits")
    if try_header("unordered_map")
        checking_for "unordered_map" do
            $defs.push(format("-DHAVE_STD_%s", "unordered_map".tr_cpp))
        end
    end
    have_header("tr1/unordered_map")
    if try_header("unordered_set")
        checking_for "unordered_set" do
            $defs.push(format("-DHAVE_STD_%s", "unordered_set".tr_cpp))
        end
    end
    have_header("tr1/unordered_set")
    have_header("wx/preferences.h","wx/defs.h")
    #check for better Bind commmand
    unless have_macro("wxHAS_EVENT_BIND","wx/wx.h")
        abort("need wxHAS_EVENT_BIND, update your compiler!")
    end

@@ -104,7 +174,7 @@ if(wx_config = find_executable('wx-config'))
have_const("wxFD_NO_FOLLOW","wx/filedlg.h")
have_const("wxDIRCTRL_DEFAULT_STYLE",["wx/wx.h", "wx/dirctrl.h"])
have_func("wxDirCtrl()",["wx/wx.h", "wx/dirctrl.h"])
have_const("wxSTC_LEX_DMAP",["wx/wx.h", "wx/stc/stc.h"])
have_const("wxSTC_LEX_DMAP",["wx/wx.h", "wx/stc/stc.h"])

    have_const("wxALIGN_CENTER_VERTICAL","wx/sizer.h")
    have_member_func("wxSizerFlags","CenterVertical","wx/sizer.h")

@@ -124,7 +194,7 @@ CONFIG["warnflags"].gsub!(
"-Wextra" #wxAUI is a bit buggy
), "")

with_cppflags("-std=c++11") {

with_cppflags("-std=c++11") {
create_header
create_makefile "rwx"

}

}

@Hanmac
Copy link
Owner

Hanmac commented May 28, 2015

is it my problem when ruby with clang on osx is broken? (i currently havnt a osx machine to test it)
try to use a newer ruby/clang version that doesnt seems to break that much

also in your issue its difficult to read what changes i need to do,
can you make a clone, commits and a pull request so i can see what should be done?

@rinkevichjm
Copy link
Author

I need to figure out how to make a pull request. I'm using Xcode 5 and the apple clang. On OS X wx uses clang directly while ruby uses gcc and "clang"!="gcc" however clang -v 2>&1 and gcc -v 2>&1 have matching lines as they are the same compiler.
And rvm installing some prebuilts binaries results in LDFLAGS having "-L/Users/xxxx/" which don't exist and cause the ld to error in building the bundle.

Sent from my iPhone

On May 27, 2015, at 11:26 PM, Hans Mackowiak [email protected] wrote:

is it my problem when ruby with clang on osx is broken? (i currently havnt a osx machine to test it)
try to use a newer ruby/clang version that doesnt seems to break that much

also in your issue its difficult to read what changes i need to do,
can you make a clone, commits and a pull request so i can see what should be done?


Reply to this email directly or view it on GitHub.

@rinkevichjm
Copy link
Author

pull changes from https://github.com/rinkevichjm/rwx.git

On Wed, May 27, 2015 at 11:52 PM, James Rinkevich [email protected]
wrote:

I need to figure out how to make a pull request. I'm using Xcode 5 and the
apple clang. On OS X wx uses clang directly while ruby uses gcc and
"clang"!="gcc" however clang -v 2>&1 and gcc -v 2>&1 have matching lines as
they are the same compiler.
And rvm installing some prebuilts binaries results in LDFLAGS having
"-L/Users/xxxx/" which don't exist and cause the ld to error in building
the bundle.

Sent from my iPhone

On May 27, 2015, at 11:26 PM, Hans Mackowiak [email protected]
wrote:

is it my problem when ruby with clang on osx is broken? (i currently havnt
a osx machine to test it)
try to use a newer ruby/clang version that doesnt seems to break that much

also in your issue its difficult to read what changes i need to do,
can you make a clone, commits and a pull request so i can see what should
be done?


Reply to this email directly or view it on GitHub
#11 (comment).

@rinkevichjm
Copy link
Author

The changes now pass those tests some sort of issue with pkg_config of gtk files. Were you having problems with that? this should fix those too.

@rinkevichjm
Copy link
Author

the correct test for clang with libc++ is

have_macro("_LIBCPP_VERSION","ciso646") # The C++ specification
specifically says that #include has no effect.

On Thu, May 28, 2015 at 8:56 PM, James Rinkevich [email protected]
wrote:

pull changes from https://github.com/rinkevichjm/rwx.git

On Wed, May 27, 2015 at 11:52 PM, James Rinkevich [email protected]
wrote:

I need to figure out how to make a pull request. I'm using Xcode 5 and
the apple clang. On OS X wx uses clang directly while ruby uses gcc and
"clang"!="gcc" however clang -v 2>&1 and gcc -v 2>&1 have matching lines as
they are the same compiler.
And rvm installing some prebuilts binaries results in LDFLAGS having
"-L/Users/xxxx/" which don't exist and cause the ld to error in building
the bundle.

Sent from my iPhone

On May 27, 2015, at 11:26 PM, Hans Mackowiak [email protected]
wrote:

is it my problem when ruby with clang on osx is broken? (i currently
havnt a osx machine to test it)
try to use a newer ruby/clang version that doesnt seems to break that much

also in your issue its difficult to read what changes i need to do,
can you make a clone, commits and a pull request so i can see what should
be done?


Reply to this email directly or view it on GitHub
#11 (comment).

@Hanmac
Copy link
Owner

Hanmac commented Jun 4, 2015

i added have_macro("_LIBCPP_VERSION","ciso646") for extra checking but i need to make the stdlib option optional because i cant check if wxwidgets is build against it or not, and if it isnt it will cause runtime errors.
i probably need to add an optional flag for c++11 too.

means i got 2 * 2 different configurations (and even more) because of yes/no libc++ and yes/no c++11
and i am totally unsure how the different settings are mixable.
(the gem and wx does want to be build against the same c++ lib and hopefully against the same c++XX version)

PS: you did compile wxwidgets and maybe ruby on purpose with libc++ and c++11 right? because without everything would be fine.

@rinkevichjm
Copy link
Author

I have MAC OS X Yosemite so clang is built with libc++. I wish I knew what the build set up for that is. I look around as it may be a configure or cmake option.

Sent from my iPhone

On Jun 4, 2015, at 8:16 AM, Hans Mackowiak [email protected] wrote:

i added have_macro("_LIBCPP_VERSION","ciso646") for extra checking but i need to make the stdlib option optional because i cant check if wxwidgets is build against it or not, and if it isnt it will cause runtime errors.
i probably need to add an optional flag for c++11 too.

means i got 2 * 2 different configurations (and even more) because of yes/no libc++ and yes/no c++11
and i am totally unsure how the different settings are mixable.
(the gem and wx does want to be build against the same c++ lib and hopefully against the same c++XX version)

PS: you did compile wxwidgets and maybe ruby on purpose with libc++ and c++11 right? because without everything would be fine.


Reply to this email directly or view it on GitHub.

@rinkevichjm
Copy link
Author

Looking ing the mac ports port file for clang 3.6 suggests that setting the option --cxx_stdlib=libc++ will cause clang to be built with Libc++ as the default library, so you could configure build and install that. I'd think that if you could build a binary of that and just install the binary for tests that would be what is needed.

Sent from my iPhone

On Jun 4, 2015, at 8:16 AM, Hans Mackowiak [email protected] wrote:

i added have_macro("_LIBCPP_VERSION","ciso646") for extra checking but i need to make the stdlib option optional because i cant check if wxwidgets is build against it or not, and if it isnt it will cause runtime errors.
i probably need to add an optional flag for c++11 too.

means i got 2 * 2 different configurations (and even more) because of yes/no libc++ and yes/no c++11
and i am totally unsure how the different settings are mixable.
(the gem and wx does want to be build against the same c++ lib and hopefully against the same c++XX version)

PS: you did compile wxwidgets and maybe ruby on purpose with libc++ and c++11 right? because without everything would be fine.


Reply to this email directly or view it on GitHub.

@Hanmac
Copy link
Owner

Hanmac commented Jun 5, 2015

you still not know what i mean right?
i said that my rwx CANT KNOW (yet) if wxwidgets is build against libc++ or not

setting --cxx_stdlib=libc++ as default doesnt solve my problem

and the problem is if wxwidgets is build with libc++, not clang

@rinkevichjm
Copy link
Author

But you need to be able to test with clang as is being built on OS X or FreeBSD. Where if --stdlib is not set libc++ is used. No?

Sent from my iPhone

On Jun 4, 2015, at 8:17 PM, Hans Mackowiak [email protected] wrote:

you still not know what i mean right?
i said that my rwx CANT KNOW (yet) if wxwidgets is build against libc++ or not

setting --cxx_stdlib=libc++ as default doesnt solve my problem

and the problem is if wxwidgets is build with libc++, not clang


Reply to this email directly or view it on GitHub.

@Hanmac
Copy link
Owner

Hanmac commented Jun 5, 2015

No i mean i can build rwx with or without --stdlib, both of them does work

BUT if i start the program, AND wxwidgets does not have the SAME stdlib setting TOO

then it does crash.

means i need to check somehow what setting wxwidgets has

@rinkevichjm
Copy link
Author

test have_macro "HAVE_TR1_TYPE_TRAITS","wx/setup.h" # if this exists you
don't have libc++

On Thu, Jun 4, 2015 at 8:34 PM, Hans Mackowiak [email protected]
wrote:

No i mean i can build rwx with or without --stdlib, both of them does work

BUT if i start the program, AND wxwidgets does not have the SAME stdlib
setting TOO

then it does crash.

means i need to check somehow what setting wxwidgets has


Reply to this email directly or view it on GitHub
#11 (comment).

@Hanmac
Copy link
Owner

Hanmac commented Jun 5, 2015

checking for "HAVE_TR1_TYPE_TRAITS" and "HAVE_TYPE_TRAITS" is not check enough for libc++ but for c++11 (libc++ can be build without c++11 too)

but HAVE_ABI_FORCEDUNWIND is something that does not exist on libc++ (i can use that for detecting libc++)

i added checks for both settings (and mixed), so it should work for your system now

@rinkevichjm
Copy link
Author

checking for HAVE_TR1_TYPE_TRAITS in WX's setup.h is because WX's configure writes wx/setup.h, via auto configure test using the correct compiler setup. probably should flag an issue for wxwidgets team to fix configure to save -stdlib= flag from env CXXFLAGS for wx-config --cxxflags. The makefiles run with it but it but it isn't saved for wx-config

Sent from my iPhone

On Jun 5, 2015, at 2:59 AM, Hans Mackowiak [email protected] wrote:

checking for "HAVE_TR1_TYPE_TRAITS" and "HAVE_TYPE_TRAITS" is not check enough for libc++ but for c++11 (libc++ can be build without c++11 too)

but HAVE_ABI_FORCEDUNWIND is something that does not exist on libc++ (i can use that for detecting libc++)

i added checks for both settings (and mixed), so it should work for your system now


Reply to this email directly or view it on GitHub.

@Hanmac
Copy link
Owner

Hanmac commented Jun 5, 2015

no, adding libc++ does not automaticlly enable c++11,
thats extra!

did you test it if that latest changes does works for you?

@rinkevichjm
Copy link
Author

checking for HAVE_TYPE_TRAITS in wx/setup.h will tell you if c++11 is set
Sent from my iPhone

On Jun 5, 2015, at 4:09 AM, Hans Mackowiak [email protected] wrote:

no, adding libc++ does not automaticlly enable c++11,
thats extra!

did you test it if that latest changes does works for you?


Reply to this email directly or view it on GitHub.

@Hanmac
Copy link
Owner

Hanmac commented Jun 5, 2015

that is what i already told you about,
but you did say once that HAVE_TR1_TYPE_TRAITS might be enough to check between libstdc++ and libc++ which is not.

can you test it yet that if the newest changes makes it working on your osx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants