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

Use system MbedTLS #66

Closed
wants to merge 5 commits into from
Closed

Use system MbedTLS #66

wants to merge 5 commits into from

Conversation

malmaud
Copy link
Contributor

@malmaud malmaud commented Aug 14, 2016

No description provided.

@@ -31,12 +31,28 @@ else
srcsha = "8f25b6f156ae5081e91bcc58b02455926d9324035fe5f7028a6bb5bc0139a757"
end

# Use the version of MbedTLS that ships with Julia .5 and later

julia_bin = Base.julia_cmd().exec[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use JULIA_HOME, that's what this is derived from anyway - the representation of Cmd might change which could break this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@codecov-io
Copy link

codecov-io commented Aug 15, 2016

Current coverage is 70.25% (diff: 100%)

Merging #66 into master will decrease coverage by 0.51%

@@             master        #66   diff @@
==========================================
  Files            10         10          
  Lines           390        390          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits            276        274     -2   
- Misses          114        116     +2   
  Partials          0          0          

Powered by Codecov. Last update 4a92329...bdc5685

@malmaud
Copy link
Contributor Author

malmaud commented Aug 15, 2016

Travis is showing this error, even though things work locally for me. Confused ATM on what's going on.

LoadError: MethodError: no method matching generate_steps(::BinDeps.LibraryDependency, ::BinDeps.CustomPathBinaries, ::Dict{Symbol,Any})
Closest candidates are:
  generate_steps(::BinDeps.LibraryDependency, !Matched::BinDeps.AptGet, ::Any) at /Users/travis/.julia/v0.6/BinDeps/src/dependencies.jl:320
  generate_steps(::BinDeps.LibraryDependency, !Matched::BinDeps.Yum, ::Any) at /Users/travis/.julia/v0.6/BinDeps/src/dependencies.jl:331
  generate_steps(::BinDeps.LibraryDependency, !Matched::BinDeps.Pacman, ::Any) at /Users/travis/.julia/v0.6/BinDeps/src/dependencies.jl:343
  ...
while loading /Users/travis/.julia/v0.6/MbedTLS/deps/build.jl, in expression starting on line 83

@tkelman
Copy link
Contributor

tkelman commented Aug 15, 2016

CustomPathBinaries is probably not widely tested with local paths. I'm not too familiar with where in BinDeps that code is.

@malmaud
Copy link
Contributor Author

malmaud commented Aug 15, 2016

Alright. Realistically speaking, I'm probably not going to look into
patching BinDeps personally so this will remain open for the time being.

On Mon, Aug 15, 2016 at 6:47 AM Tony Kelman notifications@github.com
wrote:

CustomPathBinaries is probably not widely tested with local paths. I'm not
too familiar with where in BinDeps that code is.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#66 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA8SvZ6dEf6tpACjVUqllf7lcAbfB8MXks5qgFHJgaJpZM4JkAb7
.

# Use the version of MbedTLS that ships with Julia .5 and later

provides(Binaries,
joinpath(dirname(JULIA_HOME), "..", "lib", "julia"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of either dirname or ".." are redundant, JULIA_HOME is already the bin directory. On Windows this should be just JULIA_HOME.

# For Unix
provides(Binaries,
joinpath(JULIA_HOME, "..", "lib", "julia"),
mbed_all)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os = :Unix etc

@malmaud
Copy link
Contributor Author

malmaud commented Aug 16, 2016

On Travis, it looks like MbedTLS is still being build from source on Linux and from Homebrew on OS X, even though the final file paths in deps.jl are correctly pointing the versions bundled with Julia. So that's a behavior of BinDeps that I don't really undestand.

@PallHaraldsson
Copy link
Contributor

I do see "mbedtls (>= 2.2)" at Julia's README.md, while 2.2 is no longer listed as the supported version.

I made this #67 issue before seeing this one. You think Julia will better track security updates or just want to avoid duplicates? I did wander [for cURL], is that at least possible? Maybe better to track security updates (or not..)? [It's also a possibility that security updates for 0.4 might get neglected..]

@malmaud
Copy link
Contributor Author

malmaud commented Aug 17, 2016

The versions of Julia without a bundled MbedTLS are failing on Travis: "LoadError: Provider BinDeps.Binaries failed to satisfy dependency libmbedtls".
I thought BinDeps would automatically try a different provider in that case? But I guess not and we need to check the Julia version before adding that binary provider?

@tkelman
Copy link
Contributor

tkelman commented Aug 17, 2016

My impression was that it should also check several providers in a priority order and fall back to other options, but that might be broken?

@malmaud
Copy link
Contributor Author

malmaud commented Aug 17, 2016

So that's one question, and the other is why the linux nightly is still building MbedTLS from source, and why Homebrew is still downloading an MbedTLS on the OS X nightly, even though in the latter two cases the final paths in deps.jl actually do point to the Julia-bundled binaries. Those all seem like issues with BinDeps.


if is_unix()
provides(Binaries,
joinpath(JULIA_HOME, "..", "lib", "julia"),
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this really should not be necessary. These libraries should be picked up automatically by the RPATH that is embedded in all Julia builds to find things like sys.so. Also, this will break if someone is running Julia with relative paths to libraries that aren't ../lib/julia, such as the Debian package where it's ../lib/x86_64-linux-gnu/julia, etc....

If you don't provide this path, do things break?

@staticfloat
Copy link
Sponsor Member

staticfloat commented Sep 6, 2016

Can you embed a Bindeps.debug("MbedTLS") into your buildscript before trying to Pkg.build()? That will at least give us an idea of what BinDeps sees. You could also try running something like julia -e 'Libdl.dlopen("libmbedtls")' to see what the error message is that is causing Julia to think it doesn't have an libmbedtls laying around that it can use.

@quinnj
Copy link
Member

quinnj commented Nov 18, 2016

With julia-provided shared library, do we really need BinDeps anymore? Is that just to provide fallbacks? I'm wondering if we can't just simplify the whole process here and say const mbedlib = "libmbedtls" and be done?

@malmaud
Copy link
Contributor Author

malmaud commented Nov 18, 2016

Does that actually work right now?

On Nov 18, 2016, at 10:10 AM, Jacob Quinn notifications@github.com wrote:

With julia-provided shared library, do we really need BinDeps anymore? Is that just to provide fallbacks? I'm wondering if we can't just simplify the whole process here and say const mbedlib = "libmbedtls" and be done?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #66 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AA8SvV-1UaZW-Lc7-MnzNa0JDDgK4Decks5q_b_igaJpZM4JkAb7.

@quinnj
Copy link
Member

quinnj commented Nov 18, 2016

              _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0 (2016-09-19 18:14 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-apple-darwin13.4.0

julia> data = Libc.malloc(32)
Ptr{Void} @0x00007f8aea45d330

julia> ccall((:mbedtls_pk_init, "libmbedcrypto"), Void, (Ptr{Void},), data)

julia>

I mean, 0.5-only I would imagine, but we could bump the Julia minimum.

@malmaud
Copy link
Contributor Author

malmaud commented Nov 18, 2016

What do you think, @tkelman ? Any reason not to do this?

@staticfloat
Copy link
Sponsor Member

I'm in favor of using the julia-bundled libraries as much as we can, with the caveat that of course we always want to shrink Base as much as possible, so MbedTLS may go away some time in the future.

@quinnj to make sure that it's picking up the right libmbedcrypto, you should probably filter( x-> contains(x, "mbed"), Libdl.dllist()) after that. For my from-source build of master, things look good:

julia> filter( x-> contains(x, "mbed"), Libdl.dllist())
3-element Array{AbstractString,1}:
 "/Users/sabae/src/julia/usr/lib//libmbedtls.dylib"
 "/Users/sabae/src/julia/usr/lib//libmbedx509.dylib"
 "/Users/sabae/src/julia/usr/lib//libmbedcrypto.dylib"

@quinnj quinnj closed this Dec 1, 2016
@quinnj
Copy link
Member

quinnj commented Dec 1, 2016

Implemented in #81

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

Successfully merging this pull request may close these issues.

6 participants