{"action":"created","issue":{"url":"https://api.github.com/repos/jkozlowski/starfish/issues/8","repository_url":"https://api.github.com/repos/jkozlowski/starfish","labels_url":"https://api.github.com/repos/jkozlowski/starfish/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/jkozlowski/starfish/issues/8/comments","events_url":"https://api.github.com/repos/jkozlowski/starfish/issues/8/events","html_url":"https://github.com/jkozlowski/starfish/pull/8","id":383994377,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzMzIyODY2","number":8,"title":"Upgrade rust and SPDK to newer versions","user":{"login":"jkryl","id":5690145,"node_id":"MDQ6VXNlcjU2OTAxNDU=","avatar_url":"https://avatars3.githubusercontent.com/u/5690145?v=4","gravatar_id":"","url":"https://api.github.com/users/jkryl","html_url":"https://github.com/jkryl","followers_url":"https://api.github.com/users/jkryl/followers","following_url":"https://api.github.com/users/jkryl/following{/other_user}","gists_url":"https://api.github.com/users/jkryl/gists{/gist_id}","starred_url":"https://api.github.com/users/jkryl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkryl/subscriptions","organizations_url":"https://api.github.com/users/jkryl/orgs","repos_url":"https://api.github.com/users/jkryl/repos","events_url":"https://api.github.com/users/jkryl/events{/privacy}","received_events_url":"https://api.github.com/users/jkryl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-11-24T14:34:14Z","updated_at":"2018-11-28T08:17:29Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/jkozlowski/starfish/pulls/8","html_url":"https://github.com/jkozlowski/starfish/pull/8","diff_url":"https://github.com/jkozlowski/starfish/pull/8.diff","patch_url":"https://github.com/jkozlowski/starfish/pull/8.patch"},"body":"The primary motivation for doing that was to work around problems\r\nencountered with previous versions. However the fix is dirty.\r\nI haven't found a good solution for problem of missing\r\nrte_mempool_ring shared library so tests need to be run like this:\r\n\r\nLD_PRELOAD=/usr/local/lib/librte_mempool_ring.so.1.1 cargo test --all\r\n\r\nFor more detailed background information see discussion in issue #6 . \r\n\r\nNOTE: I don't have idea if circleci tests will pass. It's quite possible that I will\r\nhave to fix a few more things before we can merge these changes."},"comment":{"url":"https://api.github.com/repos/jkozlowski/starfish/issues/comments/442358511","html_url":"https://github.com/jkozlowski/starfish/pull/8#issuecomment-442358511","issue_url":"https://api.github.com/repos/jkozlowski/starfish/issues/8","id":442358511,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MjM1ODUxMQ==","user":{"login":"jkryl","id":5690145,"node_id":"MDQ6VXNlcjU2OTAxNDU=","avatar_url":"https://avatars3.githubusercontent.com/u/5690145?v=4","gravatar_id":"","url":"https://api.github.com/users/jkryl","html_url":"https://github.com/jkryl","followers_url":"https://api.github.com/users/jkryl/followers","following_url":"https://api.github.com/users/jkryl/following{/other_user}","gists_url":"https://api.github.com/users/jkryl/gists{/gist_id}","starred_url":"https://api.github.com/users/jkryl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkryl/subscriptions","organizations_url":"https://api.github.com/users/jkryl/orgs","repos_url":"https://api.github.com/users/jkryl/repos","events_url":"https://api.github.com/users/jkryl/events{/privacy}","received_events_url":"https://api.github.com/users/jkryl/received_events","type":"User","site_admin":false},"created_at":"2018-11-28T08:17:29Z","updated_at":"2018-11-28T08:17:29Z","author_association":"NONE","body":"Sure, so the solution consists of following pieces of code.\r\n\r\nAll dpdk/spdk static libraries need to be named explicitly In build.rs. Following function gets a list of them:\r\n```\r\nfn static_lib_list() -> Vec<&'static str> {\r\n    let mut dpdk_static_libs = vec![\r\n        \"rte_bus_pci\",\r\n        \"rte_bus_vdev\",\r\n        \"rte_eal\",\r\n        \"rte_ethdev\",\r\n        \"rte_kvargs\",\r\n        \"rte_mbuf\",\r\n        \"rte_mempool\",\r\n        \"rte_mempool_bucket\",\r\n        \"rte_mempool_ring\",\r\n        \"rte_net\",\r\n        \"rte_pci\",\r\n        \"rte_ring\",\r\n    ];\r\n\r\n    let mut spdk_static_libs = vec![\r\n        \"spdk_app_rpc\",\r\n        \"spdk_event\",\r\n        \"spdk_event_bdev\",\r\n        \"spdk_event_copy\",\r\n        \"spdk_event_iscsi\",\r\n        \"spdk_event_nbd\",\r\n        \"spdk_event_net\",\r\n        \"spdk_event_nvmf\",\r\n        \"spdk_bdev\",\r\n        \"spdk_bdev_aio\",\r\n        \"spdk_bdev_malloc\",\r\n        \"spdk_bdev_null\",\r\n        \"spdk_bdev_nvme\",\r\n        \"spdk_bdev_rpc\",\r\n        \"spdk_bdev_virtio\",\r\n        \"spdk_blob\",\r\n        \"spdk_blob_bdev\",\r\n        \"spdk_blobfs\",\r\n        \"spdk_conf\",\r\n        \"spdk_copy\",\r\n        \"spdk_copy_ioat\",\r\n        \"spdk_env_dpdk\",\r\n        \"spdk_event_scsi\",\r\n        \"spdk_event_vhost\",\r\n        \"spdk_ioat\",\r\n        \"spdk_iscsi\",\r\n        \"spdk_json\",\r\n        \"spdk_jsonrpc\",\r\n        \"spdk_log\",\r\n        \"spdk_log_rpc\",\r\n        \"spdk_lvol\",\r\n        \"spdk_nbd\",\r\n        \"spdk_net\",\r\n        \"spdk_nvme\",\r\n        \"spdk_nvmf\",\r\n        \"spdk_rpc\",\r\n        \"spdk_rte_vhost\",\r\n        \"spdk_scsi\",\r\n        \"spdk_sock\",\r\n        \"spdk_sock_posix\",\r\n        \"spdk_spdk_mock\",\r\n        \"spdk_thread\",\r\n        \"spdk_trace\",\r\n        \"spdk_util\",\r\n        \"spdk_vbdev_raid\",\r\n        \"spdk_vbdev_error\",\r\n        \"spdk_vbdev_gpt\",\r\n        \"spdk_vbdev_lvol\",\r\n        \"spdk_vbdev_split\",\r\n        \"spdk_vbdev_passthru\",\r\n        \"spdk_vhost\",\r\n        \"spdk_virtio\",\r\n        \"spdk_env_dpdk\",\r\n    ];\r\n\r\n    dpdk_static_libs.append(&mut spdk_static_libs);\r\n    dpdk_static_libs\r\n}\r\n\r\n... somewhere in main():\r\n    for lib in static_lib_list() {\r\n        println!(\"cargo:rustc-link-lib=static={}\", lib);\r\n    }\r\n```\r\n\r\nthe code which references a symbol from the library which needs to be loaded is:\r\n```\r\n// XXX This is a hack to require librte_mempool_ring library which is otherwise\r\n// excluded by rustc because no symbols are used from it. However it contains\r\n// important constructor without which all mempool allocations fail.\r\nextern \"C\" {\r\n    fn mp_hdlr_init_ops_mp_mc();\r\n}\r\npub fn force_librte_mempool_ring_load() {\r\n    unsafe {\r\n        // this call does not make any harm because if it is run second time\r\n        // it returns EEXIST\r\n        mp_hdlr_init_ops_mp_mc();\r\n    }\r\n}\r\n```\r\nThe best place to put this is probably in lib.rs in spdk-sys where the generated bindings are included so that it does not have to be repeated for each binary that is linked with spdk-sys. And that should be it, looks simple now :-)\r\n\r\nbtw when using static libraries, the spdk/dpdk does not need to be installed to /usr/local anymore. It could be included in the repo in form of a git submodule and static libraries and headers can be used from that location. It's just an option to consider, not necessarily better than what we do now.\r\n\r\nI dared to open a rust issue so that we don't need to use this workaround in long term: https://github.com/rust-lang/rust/issues/56306 ."}}
{"actor":{"display_login":"jkryl"}}